Tag Info

Hot answers tagged

1

You might not have permissiosns to see that file. You should also add a check for file existence like : SPFile u = l.RootFolder.Files.Add(l.RootFolder.Url + "/" + f.Name, f.OpenBinary(), true); if (l.Exists) { l.RootFolder.Update(); l.Update(); w.Update(); }


1

Verify that your $file.Name is truly "myfile.docx". Try these amended lines (with the other lines as is): $DestUrl ="MyDocuments/SubFolderName/" $file.MoveTo($DestUrl + $file.Name, true)


1

Use ItemAdding to prepare file for uploading and ItemAdded to kick off bussiness logic. This means, in your case, I would put all the code in ItemAdding event. In this way you can utilize properties.AfterProperties to rename file. properties.AfterProperties["Title"] = szNewFileName; Also, I'd recommended to access SPWeb as SPWeb web = ...



Only top voted, non community-wiki answers of a minimum length are eligible