1

This is what i'm trying to do in my application:

On startup, the application searches for specific files (*.txt for example) in a specific folder (let's say c:\testfolder + all subfolders) and stores their path in a simple string[]. Some files might be located in the root-folder (c:\testfolder), some files have additional subfolders (c:\testfolder\subfolderA\subfolderB).

Now, when I click on a button, all selected files are moved to a temp-folder (like c:\testfolder\temp). When I now close and reopen the application, I want to move all files from the temp-folder to their original location. Obviously this won't work, since the original path was overwritten after restarting the app.

This might be an easy task, but could someone maybe give me hint on how I could do this?

/edit

Would it be possible to ignore a specific folder (temp-folder in this case) when searching for files? Basically moved files are ignored & the old path is still saved (in Properties.Settings. for example) from the first start.

Current code I'm using to get all files:

var files = Directory.EnumerateFiles(file_path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".jpg") || s.EndsWith(".png"));
IanRawz
  • 19
  • 1
  • 5
  • 5
    You could save their original location into a file then read the file upon reopening the application to start the moving process. – John Odom May 11 '15 at 20:59
  • 1
    Serialize your string array and save it to disk. – Justin Ryan May 11 '15 at 21:00
  • 1
    If you want the original path to _persist_ until the next time you need it, then you will have to _persist_ the path to _persistent_ storage. – John Saunders May 11 '15 at 21:34
  • Thank you for your answers, but I came up with an idea that might solve my problem: Would it be possible to ignore a specific folder (temp-folder in this case) when searching for files? Basically moved files are ignored & the old path is still saved (in `Properties.Settings.` for example) from the first start. – IanRawz May 12 '15 at 02:54

0 Answers0