Home > Net > C # file operations consult these two methods have concise writing
C # file operations consult these two methods have concise writing
Time:09-22
Method one: GetFileNames (string filePath) Obtain the specified path folder (filePath such as c: \ Files) all file names (as long as the name, don't bring path) Method 2: used by CopyFile (string path1, string path2) Copy the specified File (a single File, the path is path1, such as c: \ a.t xt), to the target folder path (path2, such as d: \ File),
Search on the Internet for a day, didn't find a suitable, New small white, the great god give directions,
CodePudding user response:
Var file name=System. IO. Path. GetFileName (complete file Path);
Didn't understand The somebody else write good function, how to simplify
CodePudding user response:
public static string [] take all folder name folder (string) { Return to the Directory GetFiles (folder) The Select (x=& gt; Path. The GetFileName (x)) The ToArray (); }