Recently, you need to create a batch of images.
I used two upload methods.
Method 1:
Function: Copy all objects and files under a certain category to the target category, that is, create a copy of a file catalog.
Idea: first copy all the files under the category, and then follow the example below.
Number 1: The name of the object to be copied (original object). If the object does not exist
Number 2: target object name. If the object does not existProgramWill create
1 Static Void Directorycopy ( String Sourcepath, String Destpath)
2 {
3 If ( ! Directory. exists (sourcepath ))
4 {
5 // Always
6 Throw New Directorynotfoundexception ( " The original router did not find " );
7 }
8
9 If ( ! Directory. exists (destpath ))
10 {
11 // Create a project by yourself
12 Directory. createdirectory (destpath );
13 }
14
15 Directoryinfo dir = New Directoryinfo (sourcepath );
16 Directoryinfo [] dirs = Dir. getdirectories ();
17
18 // Copy all the files under the project
19 Copyfile (Dir, destpath );
20
21 If (Dirs. Length > 0 )
22 {
23 Foreach (Directoryinfo temdirectoryinfo In Dirs)
24 {
25 String Sourcedirectoryfullname = Temdirectoryinfo. fullname;
26 String Destdirectoryfullname = Sourcedirectoryfullname. Replace (sourcepath, destpath );
27
28 If ( ! Directory. exists (destdirectoryfullname ))
29 {
30 Directory. createdirectory (destdirectoryfullname );
31 }
32
33 // Copy all files under temdirectoryinfo
34 Copyfile (temdirectoryinfo, destdirectoryfullname );
35
36 // Please refer to the following link for more information:
37 Directorycopy (sourcedirectoryfullname, destdirectoryfullname );
38 }
39 }
40 }
Method 2:
Function: Copy all objects in a specified object
Obtain the information groups of all files under the original object, and copy them in sequence.
Metric 1: category to be copied (original category)
Metric 2: Target metric name
1 Static Void Copyfile (directoryinfo path, String Destpath)
2 {
3 String Sourcepath = Path. fullname;
4
5 Fileinfo [] files = Path. getfiles ();
6
7 Foreach (Fileinfo File In Files)
8 {
9 // Full name of the original file to be copied
10 String Sourcefilefullname = File. fullname;
11 // Full name of the target file
12 String Destfilefullname = Sourcefilefullname. Replace (sourcepath, destpath );
13 // Start copy file
14 File. copyto (destfilefullname, True );
15 }
16 }
License
Directorycopy (@ "E: \ PC drive", @ "C: \ TEM \ PC drive ");
E: \ PC drive category