Click here to Skip to main content
15,943,103 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello sir,

I have two codes
First code is for uploading files on the server
Second code is to replace existing file on server

I have uploaded pdf file abc.pdf on server
next time i will do reupload with same file ie, abc.pdf

string path;
      HttpPostedFile myFile = fpProposal.PostedFile;
      int nFileLen = myFile.ContentLength;
      byte[] myData = new byte[nFileLen];
      myFile.InputStream.Read(myData, 0, nFileLen);
      path = Server.MapPath("SCANNED") + "\\" +"abc.pdf";
      if (fpProposal.HasFile)

This code is working fine for uploading and replacing/overwriting existing pdf on my local machine.
but if i try same code on server.... Uploading works... but replacing/overwriting doesn't work please help me with these...this is taking too much time.
Sushil Mate 1-Jul-13 7:13am    
you must be not having rights to overwrite on server, or someone is using that file.
sunil mali 1-Jul-13 7:56am    
Sir, Read write permission is their for that folder... thats why i am able to write,
is their something called overwrite permission if yes then let me know so that i can tell my network admistrator...
Pheonyx 1-Jul-13 7:32am    
Are you getting any exceptions being thrown? If so, what do they say?
Could it be that the system thinks the file is in use for some reason?
(use the reply feature to respond to comments so that the person who put the comment know's you have replied. I don't think you did that for your response to Sushill).
sunil mali 1-Jul-13 7:55am    
No sir its not even throwing exception....
and yes i replied against sushil's comment....
Sushil Mate 1-Jul-13 8:01am    
you have permission & u don't get any exception. its difficult to answer your question. can you delete the file first which you wanted to overwrite & try to rewrite.

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