Files\Folder
-
Hi All How can i identify root is file or folder?I have a String Path="C:\\Tets\\tr.txt" and String Path1="C:\\abc.txt".How can i identify Path root is Folder and Path1 root is File.Plz help me
Im not sure its your answer or no do you need to CString::Mid or CString::Right?
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
Hi All How can i identify root is file or folder?I have a String Path="C:\\Tets\\tr.txt" and String Path1="C:\\abc.txt".How can i identify Path root is Folder and Path1 root is File.Plz help me
See WIN32_FIND_DATA and use FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_NORMAL etc
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
Im not sure its your answer or no do you need to CString::Mid or CString::Right?
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
See WIN32_FIND_DATA and use FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_NORMAL etc
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
As you reply i use this code.
CFileFind finder;
BOOL bWorking = finder.FindFile(\_T(Path)); while (bWorking) { bWorking = finder.FindNextFile(); if (finder.MatchesMask(FILE\_ATTRIBUTE\_HIDDEN | FILE\_ATTRIBUTE\_SYSTEM)) { \_tprintf\_s(\_T("%s\\n"), (LPCTSTR) finder.GetFileName()); } }
Path="C:\\Test\\abc.txt" or Path="C:\\tets.txt".In the both case currsor enter in while loop.But I need to check String have only file or Files/Folder Both. Plz help me
-
Hi All How can i identify root is file or folder?I have a String Path="C:\\Tets\\tr.txt" and String Path1="C:\\abc.txt".How can i identify Path root is Folder and Path1 root is File.Plz help me
If the path is always the absolute path, why not check if \\ occurs more that once.
«_Superman_» I love work. It gives me something to do between weekends.
-
If the path is always the absolute path, why not check if \\ occurs more that once.
«_Superman_» I love work. It gives me something to do between weekends.
can you give me some dummy code?
CFileOperation fo;
CString string1; finalString=strFileName; char \* szMyString = (char \*)(LPCTSTR)finalString; CString string = \_T(szMyString); int nPosp = strFileName1.Find( \_T("\\\\Windows")); if( nPosp >= 0) { CString DirPath21 = strFileName1.Mid( 0, nPosp +1 ); return; } int nPosp1 = strFileName1.Find( \_T("\\\\Backup")); if( nPosp1 >= 0) { CString DirPath211 = strFileName1.Mid( 0, nPosp1 +1 ); return; } int nPosp2 = strFileName1.Find( \_T("\\\\Users")); if( nPosp2 >= 0) { CString DirPath212 = strFileName1.Mid( 0, nPosp2 +1 ); return; } CString DirPath121; int nPos = string.Find( \_T('\\\\') ,3); if( nPos >= 3) { DirPath121 = string.Mid( 0, nPos ); LPCSTR pF1=DirPath121; LPCSTR pT1="c:\\\\Backup"; if (!fo.Copy(pF1,pT1)); } else { string1=string; string1 +='\\0'; if(string1=="") { //break; } int nLen = string1.GetLength(); LPCSTR lpszBuf = string1.GetBuffer(nLen); string1.ReleaseBuffer(); LPCSTR pF=lpszBuf; LPCSTR pT="c:\\\\Backup"; if (!fo.Copy(pF,pT)); }
modified on Wednesday, March 18, 2009 8:39 AM
-
Hi All How can i identify root is file or folder?I have a String Path="C:\\Tets\\tr.txt" and String Path1="C:\\abc.txt".How can i identify Path root is Folder and Path1 root is File.Plz help me
-
Hi All How can i identify root is file or folder?I have a String Path="C:\\Tets\\tr.txt" and String Path1="C:\\abc.txt".How can i identify Path root is Folder and Path1 root is File.Plz help me
Have you checked out
_splitpath()
? Thedir
argument will contain"\tets\"
for the former and"\"
for the latter."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
can you give me some dummy code?
CFileOperation fo;
CString string1; finalString=strFileName; char \* szMyString = (char \*)(LPCTSTR)finalString; CString string = \_T(szMyString); int nPosp = strFileName1.Find( \_T("\\\\Windows")); if( nPosp >= 0) { CString DirPath21 = strFileName1.Mid( 0, nPosp +1 ); return; } int nPosp1 = strFileName1.Find( \_T("\\\\Backup")); if( nPosp1 >= 0) { CString DirPath211 = strFileName1.Mid( 0, nPosp1 +1 ); return; } int nPosp2 = strFileName1.Find( \_T("\\\\Users")); if( nPosp2 >= 0) { CString DirPath212 = strFileName1.Mid( 0, nPosp2 +1 ); return; } CString DirPath121; int nPos = string.Find( \_T('\\\\') ,3); if( nPos >= 3) { DirPath121 = string.Mid( 0, nPos ); LPCSTR pF1=DirPath121; LPCSTR pT1="c:\\\\Backup"; if (!fo.Copy(pF1,pT1)); } else { string1=string; string1 +='\\0'; if(string1=="") { //break; } int nLen = string1.GetLength(); LPCSTR lpszBuf = string1.GetBuffer(nLen); string1.ReleaseBuffer(); LPCSTR pF=lpszBuf; LPCSTR pT="c:\\\\Backup"; if (!fo.Copy(pF,pT)); }
modified on Wednesday, March 18, 2009 8:39 AM
if (strchr(string, '\\') != strrchr(string, '\\'))
root is folder.
else
root is file.Here i'm checking if the first instance of '\\' is equal to the last instance of '\\'.
«_Superman_» I love work. It gives me something to do between weekends.