How to save a local excel file in share point

public int UploadFile(string srcUrl, string destUrl)


if (!System.IO.File.Exists(srcUrl))


throw new ArgumentException(String.Format("{0} does not exist",

srcUrl), “srcUrl”);


SPWeb site = new Microsoft.SharePoint.SPSite(destUrl).OpenWeb();

System.IO.FileStream fStream = System.IO.File.OpenRead(srcUrl);

byte[] contents = new byte[fStream.Length];

fStream.Read(contents, 0, (int)fStream.Length);


//EnsureParentFolder(site, destUrl);



site.Files.Add(destUrl, contents);

return 1;


catch (Exception ex)


return 0;



// its not saving the file in the share point site :

hkhkgweb01/…/Estimate Sheet.xlsx

//The error specifying dest site cant be found.

What do you have in srcUrl? If it passes the test for File.Exists, it seems to be a local path and it can’t be used in SPSite’s constructor.

It would be easier if you told us which statement throws the error.