public
string
UploadDocument(
string
fileName,
byte
[] fileContents,
string
pathFolder)
... {
if (fileContents == null)
...{
return "Null Attachment";
}
try
...{
int iStartIndex = pathFolder.LastIndexOf("/");
string sitePath = pathFolder.Remove(iStartIndex);
string folderName = pathFolder.Substring(iStartIndex + 1);
SPSite site = new SPSite(sitePath);
SPWeb web = site.OpenWeb();
SPFolder folder = web.GetFolder(folderName);
string fileURL = fileName;
folder.Files.Add(fileURL, fileContents);
if (folder.Files[fileURL].CheckedOutBy.Name != "")
...{
folder.Files[fileURL].CheckIn("File Checked In");
}
return "File added successfully!";
}
catch (System.Exception ex)
...{
return ex.Source + ":" + ex.Message;
}
}
... {
if (fileContents == null)
...{
return "Null Attachment";
}
try
...{
int iStartIndex = pathFolder.LastIndexOf("/");
string sitePath = pathFolder.Remove(iStartIndex);
string folderName = pathFolder.Substring(iStartIndex + 1);
SPSite site = new SPSite(sitePath);
SPWeb web = site.OpenWeb();
SPFolder folder = web.GetFolder(folderName);
string fileURL = fileName;
folder.Files.Add(fileURL, fileContents);
if (folder.Files[fileURL].CheckedOutBy.Name != "")
...{
folder.Files[fileURL].CheckIn("File Checked In");
}
return "File added successfully!";
}
catch (System.Exception ex)
...{
return ex.Source + ":" + ex.Message;
}
}