Obtain the file path information TParse.
 
The driver information can be obtained based on DriveList and Drive methods.
 
 
 - DriveList requires the CDir object to save the list. Every data in the CDir object is of the TEntry type. Therefore, the drive and file information can be obtained based on TEntry.
  
 - The Drive () method obtains TDriveInfo information based on the input parameters, and obtains the iDriveAtt, iMediaAtt, iType, and iBattery Attributes Based on TDriveInfo,
Query the driver information in the sdk for detailed instructions.  
 - The Volume () method can get TVolumeInfo, which can get the drive size, available space, name and other information (the name is not available on the simulator, I do not know why)
  
 - To check whether a directory exists, use the following code:
 
   
    
     
     TInt err = fsSession. MkDir (KMessage3 ); If (err! = KErrAlreadyExists) // Don't leave if it already exists User: LeaveIfError (err ); |  
    
 
    
  
  
 
What should I do if I need to parse a file with a full path?
You can use the TParse object. When using the Parse object, you must first use the Set method to assign a full Path string, and then use FullName (), Drive (), Path (), ext (), Name ()
Obtain the full name, drive name, path, extension, and name respectively.
 
See the following example.
 
 
  
   
   Void parseNames (const TDesC & aFileName ); Void fileNames () { _ Annotate (KFuncName, "\ nDoParsing () \ n "); Console-> Printf (KFuncName ); _ Partition (KParse1, "d: \ path \ fn. ext "); ParseNames (KParse1 ); _ Partition (KParse2, "autoexec. bat "); ParseNames (KParse2 ); _ Commit (KParse3, "c: readme "); ParseNames (KParse3 ); _ Partition (KParse4, "c: \ include \ stdio. h "); ParseNames (KParse4 ); _ Partition (KParse5, ". prof. ile "); ParseNames (KParse5 ); _ Partition (KParse6, "autoexec .*"); ParseNames (KParse6 ); } Void parseNames (const TDesC & aFileName) { User: LeaveIfError (ifs. Connect ()); _ Annotate (KFullName, "Full name = % S \ n "); _ Partition (KPathComponents, "Dirve = % S path = % S name = % S ext = % S \ n "); _ Resolve (KFullNameText, "full name against session path = % S \ n "); _ Partition (KExtension, ". txt "); _ Partition (KParsePath, "FullName against session path and default extension. txt = % S \ n "); TParse p; User: LeaveIfError (p. Set (aFileName, NULL, NULL )); Console-> Printf (KFullName, & p. FullName ()); TFileName driveName (p. Drive ()); TFileName pathname (p. Path ()); TFileName filename (p. Name ()); TFileName extension (p. Ext ()); Console-> Printf (KPathComponents, & driveName, & pathname, & Filename, & extension ); User: LeaveIfError (ifs. Parse (aFileName, KExtension, p )); Console-> Printf (KParsePath, & (p. FullName ())); Ifs. Close (); } |  
  
 
  
 
The sample code is from the sdk example.
 
 
  
Anping 2009 @ original
Qi_jianzhou@126.com