Click here to Skip to main content
16,019,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am creating C#.Net Window application in visual studio 2008 and sqlserver 2005.

How to Update Uploaded file. In my application file uploading successfully.
but problem is during Update time.
I am using this code;
C#
string path = "";
for (int i = 0; i < lstFilePaths.Items.Count; i++)
   {
   if (lstFilePaths.Items.Count > 0)
      {
      string fpath = Application.StartupPath + "\\UPLOAD";
      if (Directory.Exists(fpath) != true)
         {
         Directory.CreateDirectory(fpath);
         }
      FileInfo fInfo = new FileInfo(fpath);
      string s = lstFilePaths.Text;
      string s1 = lstFilePaths.Items[i].ToString();
      string[] ar = s1.Split('\\');
      Int32 cnt = ar.Length;
      path1 = Application.StartupPath + "\\UPLOAD\\" + ar[cnt - 1].ToString();
      if (File.Exists(path1))
         {
         File.Delete(path1);
         }
      path += " ," + path1;
      File.Copy(s1, path1, true); // Here Error Occurred
      }

then I am Writing query.. of update using stored procedure.....
Hope For The favorable response.
Thanks In Advance

[edit]Indentation added to code fragment - OriginalGriff[/edit]
Posted
Updated 24-Feb-11 21:47pm
v3
Comments
Sandeep Mewara 25-Feb-11 3:38am    
What error? Post that as a comment or update question with it.
coolestCoder 25-Feb-11 5:52am    
if you look at http://msdn.microsoft.com/en-us/library/9706cfs5%28v=VS.90%29.aspx, you will know what exceptions are thrown by the "Copy" method while trying to copy a file. That may give you a hint to correct the issue. BTW, enough information is not provided to give an exact solution.
Piccadilly Yum Yum 7-Mar-11 7:55am    
check rights on directory also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900