Hi,
First off here is the structure of my site
- Root site
- Meeting Workspace
- Meeting Documents Library (with a content type using a word document template)
- Folder 1
- Folder 2
etc..
The requirement..
When a new SPFolder, like Folder 1, is created within the Meeting Document library, an event receiver creates a new list item based off the content type, into the folder. This means it will use the content type document template and put a physical word document
into that folder.
The problem
I receive a System.IO.DirectoryNotFoundException when I try to save the file to that location.
The weird part is it works 100% when it runs on a document library OUTSIDE of the meeting workspace, i.e. directly under the root site - but when the library is INSIDE the meeting workspace it gives this error. Here is my code...
private static void CreateFile(SPFolder newfolder, SPFile file)
{
Stream readStream = file.OpenBinaryStream();
SPFile uploadedFile = newfolder.Files.Add(newfolder.Url + @"/" + "Meeting Minutes.docx", readStream, true);
uploadedFile.CheckOut();
SPListItem listitem = uploadedFile.Item;
listitem["Title"] = "Meeting Minutes";
listitem.Update();
uploadedFile.Update();
uploadedFile.CheckIn(string.Empty);
}In the exception message I can copy out the URL of the folder, paste it in my browser and it successfully gets there, so the URL I am passing it is definitely valid.
If anyone has experienced this I would appreciate some help!
Thanks!