- #Windows search for file type copy with folder structure full
- #Windows search for file type copy with folder structure code
Thanks for any advice, my current solution works pretty well but I am thinking it's janky/has a lot of code smell right now?Įdit: The file path of the document is dynamically decided dependent on the environment the web service that the app is calling into is running off of. Should I be running some XCopy script on the IIS Test machine, looking at production, constantly cloning new incoming production documents into the test folders on the test machine, so they actually DO exist like the app thinks? How would you implement this? Would you not try what I am trying, and instead only look at the testing environment when running from test? (I could add a file existence check to solve that). Throw ex // if the above didnt solve and return, continue throwing w/ whatever the actual ex was file on the PRODUCTION server IF we happened to fail on devĭocumentPath = documentPath.Replace("serverdev", "server") // look at prod for document If (documentPath.Contains("serverdev")) // if there was an exception, (could probably improve the exception handling bit), try to find the Console.WriteLine("" īytes = File.ReadAllBytes(documentPath) // read the bytes of the file from the web serverĬatch (Exception ex) // didnt find the file somehow.
System.IO.FileInfo fi = new System.IO.FileInfo(file) Either that, or being able to specify file extension filters when copying a bunch of Content.
What I'd like to have is something along the lines of:Perform whatever action is required in your scenario. Hi, I'd like to copy all Content files to a target directory, but keep the file and folder structure in tact. Modify this block to perform your required task.
Perform the required action on each file here. SubDirs = System.IO.Directory.GetDirectories(currentDir) Ĭatch (System.IO.DirectoryNotFoundException e)įiles = System.IO.Directory.GetFiles(currentDir) Data structure to hold names of subfolders to be
#Windows search for file type copy with folder structure full
Public static void TraverseTree(string root) Now, downloads is read-only, and dump has full access for folder shared called downloads, and a folder shared called dump. I'm trying to make a program can copy files without using py and i have play around some functions like the code below but i wanna find a way to copy entire directory using "TraverseTree" function along with the code in the main function, such as make "TraverseTree" create directory and sub-directory folders then make the code in the main function copy files to these directories.