I have an image, person1.png
, and four other images, person2.png
, person3.png
, person5.png
, and person4.png
. I want to rename these images in C# code. How would I do this?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
On Windows Phone 7 the API methods to copy or move (rename) a file don't exist. (See http://msdn.microsoft.com/en-us/library/57z06scs(v=VS.95).aspx) You therefore have to do this yourself.
Something like:
Since the PNG files are in your XAP, you can save them into your IsolatedStorage like this:
Here you can save it to whatever file name you want by changing
IMAGE_NAME
.To read it out again, you can do this:
When you upload image this function auto change the image name to Full date and return the full path where the image saved and with it new name.
and this is the function
if you need more help i'll try :)
Use the FileInfo.MoveTo method documented here. Moving a file to the same path but with a different name is how you rename files.
FileInfo fInfo = new FileInfo ("path\to\person1.png"); fInfo.MoveTo("path\to\newname.png")
If you need to manipulate paths, use the Path.Combine method documented here