ಚುರುಕಾದ & ಸುಲಭ: ಕ್ರಿಯೆಯನ್ನು ರಿಸೀವರ್ ಮೂಲಕ ಶೇರ್ಪಾಯಿಂಟ್ ಆಬ್ಜೆಕ್ಟ್ ಮಾಡೆಲ್ ಬಳಸಿ ಅಪ್ಲೋಡ್ ಮಾಡಿದ ಫೈಲ್ ಮರುಹೆಸರಿಸಿ

ನವೀಕರಿಸಲು: This works but there are significant limitations which are described in the comments. This may still be useful in some cirumstances.

ನವೀಕರಿಸಲು 2: ನನ್ನ ಪ್ರಸ್ತುತ ಯೋಜನೆಯಲ್ಲಿ, users always upload documents. ಪರಿಣಾಮವಾಗಿ, I don’t run into a problem where MS Word is running and thinks that the file was renamed on it. I did run into a problem, "the file was modified by someone else" and solved this via a simple semaphore type flag. Users need to change a meta data field from its default value to something else. The itemupdated() ರಿಸೀವರ್ ವಾಸ್ತವವಾಗಿ ಮರುಹೆಸರಿಸು ಪ್ರದರ್ಶನ ಮೊದಲು ಮತ್ತು ನಂತರ ಅಲ್ಲಿ ಒಂದು ಮಾನ್ಯವಾದ ಮೌಲ್ಯವನ್ನು ಹುಡುಕುತ್ತದೆ, I have not had any problems. Your mileage may vary.

I have a client requirement to change the name of files uploaded to a specific document library to conform with a particular naming convention. The API does not provide a "rename()" ವಿಧಾನ. ಬದಲಿಗೆ, ನಾವು ಬಳಸಿ "MoveTo(…)". Here is a minimal bit of code to accomplish this:

 ಸಾರ್ವಜನಿಕ ಸ್ವಯಂಚಾಲನೆಯ ಸ್ತಂಭನ ಶೂನ್ಯವಾಗುವ ItemAdded(SPItemEventProperties ಗುಣಗಳು)
        {
            SPFile ಎಫ್ = properties.ListItem.File;

            f.MoveTo(properties.ListItem.ParentList.RootFolder.Url + "/xyzzy.doc");
            f.Update();

        }

The only tricky bit is the "properties.ListItem.ParentList.RootFolder.Url". The MoveTo() method requires a URL. That mashed up string points me to the root folder of my current document library. This allows me to avoid any hard coding in my event receiver.

ಇದೇ ಕೆಲಸ ಮಾಡುವ ಒಂದು ಹೆಚ್ಚು ಉಪಯುಕ್ತ ಆವೃತ್ತಿಯಾಗಿದೆ, but assigns the name of the file to "Title":

 ಸಾರ್ವಜನಿಕ ಸ್ವಯಂಚಾಲನೆಯ ಸ್ತಂಭನ ಶೂನ್ಯವಾಗುವ ItemAdded(SPItemEventProperties ಗುಣಗಳು)
        {
            DisableEventFiring();

            // ಫೈಲ್ ಸ್ವತಃ ಹೆಸರಿನ ಈ ಐಟಂ ಶೀರ್ಷಿಕೆ ನಿಗದಿಪಡಿಸಿ.
 // ಟಿಪ್ಪಣಿ: ನಾವು ಫೈಲ್ ಸ್ವತಃ ಮಾರ್ಪಡಿಸಿ ಮೊದಲು ಈ ಹುದ್ದೆ ನಡೆಯುತ್ತವೆ ಮಾಡಬೇಕು.
 // ಅಪ್ಡೇಟ್ ಕರೆ() SPFile ಮೇಲೆ ಗುಣಲಕ್ಷಣಗಳನ್ನು ಅನೂರ್ಜಿತಗೊಳಿಸುವ ತೋರುತ್ತದೆ
 // ಕೆಲವು ಅರ್ಥದಲ್ಲಿ.  Updates to "Title" ಬದಲಾವಣೆ ತನಕ ವಿಫಲವಾಗಿದೆ (ಮತ್ತು ಅಪ್ಡೇಟ್() ಕರೆ)
 // ಫೈಲ್ ಹೆಸರು ಬದಲಾವಣೆಯು ಮುಂದೆ ಸ್ಥಳಾಂತರಿಸಲಾಯಿತು.
            properties.ListItem["Title"] = Properties.ListItem.File.Name;

            properties.ListItem.Update();

            SPFile ಎಫ್ = properties.ListItem.File;

            // ಕಡತದ ವಿಸ್ತರಣೆಯನ್ನು ಪಡೆಯಿರಿ.  ನಾವು ಆ ಅಗತ್ಯವಿದೆ.
 ದಾರ spfileExt = ಹೊಸ ಫೈಲ್ ಮಾಹಿತಿ(f.Name).ಚಾಚುವುದು;

            // ಪಟ್ಟಿ ಐಟಂನ ID ಗೆ ಫೈಲ್ ಮರುಹೆಸರಿಸು ಮತ್ತು ಇರಿಸಿಕೊಳ್ಳಲು ಕಡತ ವಿಸ್ತರಣೆಯನ್ನು ಬಳಸಲು
 // ಹಾಗೇ ಇದರ ಭಾಗವನ್ನು.
            f.MoveTo(properties.ListItem.ParentList.RootFolder.Url +
                "/" + properties.ListItem["ID"] + spfileExt);

            // ನಡೆಸುವಿಕೆಯನ್ನು ಕಮಿಟ್.
            f.Update();

            EnableEventFiring();
        }

4 ಮೇಲೆ "ಆಲೋಚನೆಗಳುಚುರುಕಾದ & ಸುಲಭ: ಕ್ರಿಯೆಯನ್ನು ರಿಸೀವರ್ ಮೂಲಕ ಶೇರ್ಪಾಯಿಂಟ್ ಆಬ್ಜೆಕ್ಟ್ ಮಾಡೆಲ್ ಬಳಸಿ ಅಪ್ಲೋಡ್ ಮಾಡಿದ ಫೈಲ್ ಮರುಹೆಸರಿಸಿ

  1. ಹೆಸರಿಲ್ಲ
    ಕೂಡ, ನೀವು ಪದಗಳ ಒಳಗೆ ಇದನ್ನು ಮಾಡಿದರೆ, ಇದು ದೋಷ ಹಿಂದಿರುಗಿ ಮತ್ತು ಕಡತ ಅಸ್ತಿತ್ವದಲ್ಲಿಲ್ಲ ಹೇಳುವುದಿಲ್ಲ. ಇದು ಹೊಸ URL ಬಗ್ಗೆ ಹೇಳಲಿಲ್ಲ ಇದೆ. ನಾನು ಇನ್ನೂ ಇದರೊಂದಿಗೆ ಒಂದು ರೀತಿಯಲ್ಲಿ ಕಂಡುಬಂದಿಲ್ಲ.
  2. ಪಾಲ್ ಗಾಲ್ವಿನ್
    Thanks for pointing that out. I don’t know an answer to that one either … ಇದು ನಿರ್ವಹಿಸಿ ಹೇಗೆ ನೋಡಲು ಆಸಕ್ತಿದಾಯಕ ಆಗಿರುತ್ತದೆ.
    RE: async & ಪುನರ್ನಿರ್ದೇಶನ
    I wonder if moving it to an ItemAdding will solve it. That’s a big hole.
    ವಂದನೆ!
    –ಪಾಲ್
  3. ನದೀಮ್ Mitha
    ಫೈಲ್ ಅಸಮಕಾಲಿಕವಾಗಿ ತೆರಳಿದರು ಯಾಕೆಂದರೆ, EditForm.aspx ಮರುನಿರ್ದೇಶಿಸಲಾಗುತ್ತದೆ ಎಂದು ಒಂದು ಸಾಧ್ಯತೆಯನ್ನು ನಡೆಸುವಿಕೆಯನ್ನು ಬದ್ಧವಾಗಿದೆ ಮೊದಲು ಇರುತ್ತದೆ (ಮತ್ತು ಆ ಕೆಟ್ಟ ಇಲ್ಲಿದೆ). You’ll see that this happens if you make the code sleep before the MoveTo line. I still haven’t figured out what can be done about that problem aside from using a customized edit form.

ಒಂದು ಉತ್ತರಿಸಿ ಬಿಡಿ ನದೀಮ್ Mitha ಉತ್ತರ ರದ್ದು

ನಿಮ್ಮ ಈಮೇಲ್ ವಿಳಾಸ ರ ಆಗುವುದಿಲ್ಲ. ಅಗತ್ಯವಿರುವ ಜಾಗ ಗುರುತಿಸಲಾಗಿದೆ *