Last post Apr 05, 2007 09:09 AM by ViktorBergmanSwe
Apr 05, 2007 02:01 AM|Ranine2007|LINK
I want to open an image from a folder then to rename it and save it into other folder.
how can I rename it?as 1.gif
how can I save it again into a folder?
Please a help!
Apr 05, 2007 02:11 AM|ViktorBergmanSwe|LINK
This is very easy, although there is no specific "Rename" method in the .NET IO namespace you can use File.Moveto(oldFileName, newFileName) as the code below:
Apr 05, 2007 02:32 AM|Ranine2007|LINK
Thanks on your reply.
I got this error:
Exception Details: System.IO.FileNotFoundException: Could not find file 'E:\Microsoft Visual Studio 8\Common7\Images\default.gif'.
also this default.gif is saved on my web project solution, Please a help!
Apr 05, 2007 02:37 AM|ViktorBergmanSwe|LINK
Apr 05, 2007 02:45 AM|Ranine2007|LINK
I want to give it a path that can work on web server, to avoid problems when uploading the site on main server...
such as File.Move("http://localhost/projectname/Images/default.gif","http://localhost/projectname/Images/img/1.jpg");
still I am receiving the error???????
Apr 05, 2007 02:54 AM|ViktorBergmanSwe|LINK
"http://localhost/projectname/Images/default.gif" is not an absolute path, it's a URL.
You can get your websites absolutepath by using My.Application.Info.DirectoryPath: File.Move(My.Application.Info.DirectoryPath + "/Images/default.gif", My.Application.Info.DirectoryPath + "/Images/img/1.jpg")
Apr 05, 2007 03:03 AM|Ranine2007|LINK
what libray should I set to use My.Application.Info.DirectoryPath???
Apr 05, 2007 03:12 AM|ViktorBergmanSwe|LINK
Apr 05, 2007 03:31 AM|Ranine2007|LINK
File.Move(this.Request.ApplicationPath + "/Images/default.gif",this.Request.ApplicationPath + "/Images/img/ 1.jpg");
still the directory not found, I think that I have to set the absolute path at the webconfig, as I have no other choivce?
the error : System.IO.DirectoryNotFoundException: Could not find a part of the path Web/Images/default.gif????
Apr 05, 2007 09:09 AM|ViktorBergmanSwe|LINK