-
Idea 1, pass'\'The keyword is split into array 2, and the last part of the split array is the file name.
Also, the string is meaningless, and 2 are needed
Correlation**.
-
C Style:
char *p = strrchr(, '/'p is the last one in the path'/'address. And then.
string s(p + 1);
s is""Finish.
C Style:
int pos = '/');
POS is the last one'/'subscripts.
Then string s(+1)).
s is""Finish.
-
import
file file=new file("");
string filepath=;
In this way, public string getabsolutepath() returns an absolute pathname string for this abstract pathname.
If this abstract pathname is already an absolute pathname, the pathname string is returned, just like the getpath() method. If this abstract pathname is an empty abstract pathname, the pathname string for the current user directory is returned, as specified by the system property . Otherwise, the pathname is resolved in a system-related manner.
On UNIX systems, resolving a relative pathname based on the current user directory makes the pathname absolute. On Microsoft Windows systems, resolving a relative pathname based on the current drive directory specified by the pathname (if any) makes the pathname an absolute pathname; Otherwise, it can be resolved based on the current user directory.
Returns: An absolute pathname string that represents the same file or directory as this abstract pathname.
getpath
public string getpath() converts this abstract pathname into a pathname string. The resulting string uses the default name separator to separate the names in the name sequence.
Return: The string form (relative path) of this abstract pathname
getname
public string getname() returns the name of the file or directory represented by this abstract pathname. This name is the last name in the pathname name sequence. If the pathname name sequence is empty, an empty string is returned.
Return: The name of the file or directory represented by this abstract pathname; If the name sequence of the pathname is empty, an empty string is returned.
If you want API, I'll send you (Chinese API) and leave an email address.
API in English).
-
This problem is mainly to use the split() method of the string class to make multiple calls, and it has been implemented for you, ** as follows:
public class test}}}
-
import ;
import ;
import ;
public class test
Or you can use the lastindexof(" ") method to intercept it in the for loop, I won't write it, you can try to write it yourself.
-
Let me give you a method: if that's the case, make sure that str must contain at least one filename, and that there is some rule to distinguish between each path, let's say, between every two pathnames";"Separate.
string str = "c:/win/good/" ;
string strfilename = ";") ;Split according to your own rules.
Then determine the number of paths, and then use a loop.
string name = "/") ;to"/"To separate characters, split the string into an array of characters.
int n = ;The last content of the array is the file name you want, then name[n] is the file name.
Let's give a program:
public class testfilenamestringfor(int i=0;i<;i++)
-
You can use the getAbsoluteFile() method in the file class to get it directly.
-
The above method can also be used, I can get the name directly, and I don't need to convert it to a file object file file=new file("d:\\");
string test;
test=;
for(int i=0;i<;i++)
-
If you want to get the file name in the current file, you just need string filename = ; That's it. If you want to include the filenames in the file, you can do so recursively. Here are two specific implementations.
where public static string getfilename(string path) is to get only the file name in the current file. Public Static Void GetAllFileName(String Path, ArrayListFileName) is the file name that includes the current file and its subfiles.
public class getfilename
public static void getallfilename(string path,arraylistfilename)}}
public static void main(string args)
arraylistlistfilename = new arraylist();
getallfilename("f:\\xiaoshuo",listfilename);
for(string name:listfilename)}}
The specific folder needs to be changed at runtime.
-
import ;
public class dir }}
This is to get the file names of all files in the current directory, including the names of files and folders, if you want to distinguish between files and folders, please use isdirectory() to judge, if you don't know, please check the manual.
Here's how to get Wealth Value:
Know the value of wealth: >>>More
Hello. Know the value of wealth].
1 New users log in for the first time 20 Complete the activation of the account2 Be 20 Bounty Points The person who asked the question is, or is selected by voting, will receive the 20 Bounty Points set by the system automatically given by the system. >>>More
Hello netizens!
1. Set 2**3 Click on the SIM card PIN code. >>>More
1. Distinguish scenario-based comments.
First of all, it is recommended that sellers ask for reviews in a differentiated way, and do not send emails to every buyer who buys the product to ask for a review, because this kind of behavior is not only not allowed by Amazon, but also may cause customer dissatisfaction and leave bad reviews because of your large number of insincere and insincere requests for reviews. >>>More
1. The power company only froze the meter of your home at 12 o'clock in the morning every day. So the electricity bill you see is based on the data in the early morning of the day, and your data for the day is not calculated. 2. The implementation of a step-by-step calculation method for residential electricity prices will affect the calculation of electricity charges. >>>More