|
i use find ,mid and Right.But i need to check only root is Folder or Not?
|
|
|
|
|
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
|
|
|
|
|
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=="")
{
}
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.
|
|
|
|
|
You might be searching for PathIsRoot API...
- ns ami -
|
|
|
|
|
Have you checked out _splitpath() ? The dir 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
|
|
|
|
|
Hi ,
Can you please tell me how shuold i check compiler setting in visual studio 20005.
Thanks,
|
|
|
|
|
by going to Project->Properties, if you are looking for compiler setting for your specific project
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Friday, March 6, 2009 6:26 AM
|
|
|
|
|
Is this your question? "Tools->Option"
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,
I want to Parse a Command line Argument of the format
Application -d<filename><filesize> -r <fiename> <no of="" files="">
where application name is application name, <filename> and <filesize> are optional arguments for -d and similiar is the case od -r.
I m using getopt() for parsing, but I am not able to get the third argument of -d.
Can you please help me.
Its urgent..!
Thanks in advance,
Purusottam Mishra
Purusottam Mishra
Systems Executive
|
|
|
|
|
- What has your question to do with
Visual C++/MFC ? Raj-Ekoham DwitiyoNasti wrote: I m using getopt() for parsing, but I am not able to get the third argument of -d.
Raj-Ekoham DwitiyoNasti wrote: Its urgent..!
This makes your question automatically falling down to the bottom of the stack.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Although this has nothing to do with MFC,this is completely related to C++(GNU Compiler).
Purusottam Mishra
Systems Executive
|
|
|
|
|
Could you please elaborate a bit your question (for instance make an example)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
if I am to Parse a Command line of type:
MyApplication [-v] [-i [filename] | -c [filename] [(-s e|c|v ) | ( -m c|V|v num_passes ) | (-r read:write ratio number_of cycles ) | -id ] [ -d devicenumber] [-o filename]
I m parsing it like:
int main(int argc,char* argv[])
{
char *options,*value;
while(int Opt = getopt(argc,argv,"s ::v:")!=-1)
{
switch(Opt)
{
case 'v':
//Do Something
break;
case 'm':
options = optarg;
while(*options != '\0')
{
switch(getsubopt(&options,&myopts,&value))
{
case 'r' :
cout<<optarg<<endl;
break;
case 'p' :
cout<<optarg<<endl;
break;
}
++optind;
}
break;
}
}
}
then suppose I give the command Like:
My Application -m v 5
Then I should Be able to retrieve 'v' Value and the value 5(Please refer to Comand Line format above).
Thanks agai for ur quick reply.
Purusottam Mishra
Systems Executive
|
|
|
|
|
Please include your code snippet inside <pre> tags (using 'code block' button), I cannot recognize what are you passing to getopt .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
int main(int argc,char* argv[])
{
char *options,*value;
while(int Opt = getopt(argc,argv,"s:d:v:")!=-1)
{
switch(Opt)
{
case 'v':
break;
case 'm':
options = optarg;
while(*options != '\0')
{
switch(getsubopt(&options,&myopts,&value))
{
case 'r' :
cout<<optarg<<endl;
break;
case 'p' :
cout<<optarg<<endl;
break;
}
++optind;
}
break;
}
}
}
Purusottam Mishra
Systems Executive
|
|
|
|
|
Looking at you code I cannot understand how could you hope to get the 'm' option.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have a dialog based application which has a tab control containing a handful of tabs.
For each tab dialog I have overriden the OnOK() and OnCancel() function with (empty) virtual ones, such that when inside the tab the Enter key or ESC key respectively doesn't let the tab content (child dialog resource, derived from CDialog) disappear (Thanks for the hint Cedric)
So far so good. All that works(worked) fine.
To be able to not only 'tab' within the tab control itself, but also out of it to the other controls (e.g. buttons) in my main dialog based application, I have selected the "Control Parent" check box in the Extended Styles for each child dialog.
Again that does the trick and I can now hop happily into the tab control, tab through all the controls there, and - after the last child control - I can tab out again to some of the other controls of the main window.
However, since I have selected the 'contrl parent' feature, all my "effort" regarding the overriding of OnOK) and OnCancel() seems to have been in vain, as now the ESC key or ENTER key will close the whole application, basically terminating my application.
I assume that somehow the repective messages get still handled/mapped and hence will be processed by the application to call a "Now-shut-down-the-whole-lot-please"-function, but I just don't have any idea how to avoid that.
I hope this makes sense. Any help would be most appreciated. Many thanks.
|
|
|
|
|
Maybe you could override the OnOK() and OnCancel() of the main dialog on which the tab control is placed.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
As the other reply, you need to override the OnOK and OnCancel in the main dialog too.
But remember to map the WM_CLOSE to OnClose and call EndDialog there. If not your application cannot be closed by clicking the Close button in the titlebar.
- ns ami -
|
|
|
|
|
Thanks guys. I tried to override the OnOK and OnCancel, and ran straight into the problem you describe, (--> couldn't close the main window at all anymore (not with the OnOK button (IDOK), nor with ALT+F4 nor with the close button in the title bar.
I actually had to kill the app via the task manager.
My problem is that I don't know how to override it properly.
Your advice regarding the mapping of WM_CLOSE etc. is probably what I need to do somehow, however, I don't have the knowledge yet what and how exactly to do it.
Would you be so kind to explain more detailed?
Thanks.
|
|
|
|
|
I tried a few more things, but can't get it to work. Still missing something here. Please help!
In the main dialog header I have addded the OnOK() and OnCancel() virtual functions manually to the area where the wizard had already put its virtual function for the DoDataExchange() override, is that the correct place?
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual void OnOK();
virtual void OnCancel();
Then I have added the ON_WM_CLOSE() message like this in the .cpp file of the main dialog:
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CONNECT, OnConnect)
ON_NOTIFY(TCN_SELCHANGE, IDC_Test_MENUS, OnSelchangeTestMenus)
ON_BN_CLICKED(IDC_OK, OnOk)
ON_BN_CLICKED(IDC_TestHELP, OnTesthelp)
ON_BN_CLICKED(IDC_SETTINGS, OnSettings)
ON_WM_CLOSE()
END_MESSAGE_MAP()
But I am stuck now. Any hints would be most appreciated.
|
|
|
|
|
Is there anyone, who could give me some hints/examples as to the problems I have with overriding the OnOK() and OnCancel() function, as per this thread?
Many thanks in advance
|
|
|
|