asp.net - Copy file from server to anoter file on same server -


I'm looking for internet search to give a good answer to this question, but nothing is there. I have a way to copy a file on the server to a new file on the same server with another name ... yes weird, I know.

When I am using the file. Path with file name:

  string newpath = (Request.Url.GetLeftPart (UriPartial.Authority) + Request.ApplicationPath) + ("Content / Images /" + p.id + ". Png ");   

which gives the local host: xxxxx / content / images / xxx.png

but it gives one:

  System. ArgumentException The URI format scanned by the user code are not supported   

How do I do this?

First of all, it depends on the type of files you want to copy if you just want to copy You want to copy files and have access to both of your app's filesystem and you are capable of using Apache Commons IO. There are convenient ways to copy files in the IO: FileUtils class:

  FileUtils.copyFileToDirectory (SrcFile, targetDirectory); Otherwise you may consider Apache Commons VFS, it provides a common API for many protocols (s) FTP, HTTP (S) resources.   

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -