hi hemant,
do you close the file stream? it sounds like the file might be locked. if
the web method is getting stuck, it may be throwing an exception that is not
being handled. are you invoking the method on another thread?
this is code i use to send a file to a win-app from a web service. it sends
the file as a byte[] to the client. notice that i have a 'finally' clause
that always closes the file.
[WebMethod]
public byte[] DownloadFile(string filename)
{
// check that dir exists
DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("bin/exec"));
if(!dirInfo.Exists)
throw new Exception("Unable to retrieve server file information.\n Path
not found for bin/exec");
string path = dirInfo.FullName + "\\" + filename;
// check that requested file exists
FileInfo f = new FileInfo(path);
if(!f.Exists)
throw new Exception("Unable to retrieve server file information.\n File
not found for " + path);
// open the file to stream as a byte[]
FileStream stream = File.OpenRead(path);
if (stream != null && stream.Length > 0)
{
try
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
return bytes;
}
catch(Exception ex)
{
throw new Exception("Failed to read from file " + filename + ".\n" +
ex.Message);
}
finally
{
stream.Close();
}
}
else
throw new Exception("Could not read file into byte array.");
}
hope this helps
tim
--------------------------
blog:
http://tim.mackey.ie
"Hemant Athavale" <He************@discussions.microsoft.com> wrote in
message news:39**********************************@microsof t.com...
I have developed a webservice which is used for LIVEUPDATES for win
application. Method is used for donwloading new files from server to
Clients
PC. It is working OK when one user is accessing method, but stuck when
many
users try to access method.
Please help what is wrong in coding
Hemant