Renaming a file in c#:
File.Move(source,Destination);
File.Delete(source);
It execute successfully, how ever when i try to rename the file again, the system gives this exception: The process cannot access the file because it is being used by another process. i cant find that where is this in use? when i further debug the error it shows me the class name is in the process of w3wp.exe which is IIS. What should i do next? getting
foreach (string folder in folder)
{
FileSystemItem item = new FileSystemItem();
DirectoryInfo di = new DirectoryInfo(folder);
item.Name = di.Name;
item.FullName = di.FullName;
item.Path = path + "\\" + item.Name;
item.CreatedDate = di.CreationTime;
item.IsFolder = true;
item.Extension = "folder";
listFolder.Add(item);
}
docList = CreatXmllist(listFolder);
return docList
this is how i am getting folder list and it is then returned to xml. then in folder i get the files when i click it
now to get the images: this is the code
public xml (string path, List<l> one)
{
List<T> tt = new List<T>();
List<T> SessionList = new List<T>();
string[] files = Directory.GetFiles(HttpContext.Current.Request.PhysicalApplicationPath + path);
foreach (string file in files)
{
FileSystemItem item = new FileSystemItem();
FileInfo i = new FileInfo(file);
string a = i.LastWriteTime.ToString();
var thumbnails = from a in b where a.Name == fi.Name select t;
if (fi.Name != "a")
if (t.Count() == 0)
{
r session r = new r();
r.aName = fi.aName;
SessionList.Add(r);
fi.Exists;
}
else
t.Add((T)t.First());
}
You don't need to call the File.Delete as part of the rename, you would have needed it if you did a copy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With