I would like to upload multiple files in Sharepoint "Shared Documents" with user control this is my ascx :
<asp:FileUpload ID="fileBrowse" runat="server" />
<asp:Button ID="fileUpload" runat="server" Text="Upload Files" OnClick="fileUpload_Click" />
and my code behind :
protected void fileUpload_Click(object sender, EventArgs e)
{
if (fileBrowse.HasFile)
{
string filename = fileBrowse.PostedFile.FileName;
// string allpath = Path.GetFileName(fileBrowse.PostedFile.FileName);
// string all = Path.GetFullPath(fileBrowse.PostedFile.FileName);
String fileToUpload = @filename;
String sharePointSite = "http://.../sites/GM/";
String documentLibraryName = "Shared Documents";
using (SPSite oSite = new SPSite(sharePointSite))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
if (!System.IO.File.Exists(fileToUpload))
throw new FileNotFoundException("File not found.", fileToUpload);
SPFolder myLibrary = oWeb.Folders[documentLibraryName];
// Prepare to upload
Boolean replaceExistingFiles = true;
String fileName = System.IO.Path.GetFileName(fileToUpload);
FileStream fileStream = File.OpenRead(fileToUpload);
// Upload document
SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);
// Commit
myLibrary.Update();
}
}
}
}
it just upload 1 file, and it works in dev machine, not client machine "File not found"
Help please