Checking to see if filename entered
-
Hi all, I am having trouble coding this and wanted to know how to check if a user enters a filename to open. Basically I want to check to make sure the file name is not all spaces and that it is not blank. I am not using CFileDialog right now, just have a editbox and a browse button that i got from a CP article. Does anyone have code out there that does this? Can someone lead me in the right direction? Thanks for all your help . Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
-
Hi all, I am having trouble coding this and wanted to know how to check if a user enters a filename to open. Basically I want to check to make sure the file name is not all spaces and that it is not blank. I am not using CFileDialog right now, just have a editbox and a browse button that i got from a CP article. Does anyone have code out there that does this? Can someone lead me in the right direction? Thanks for all your help . Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
You can get at the string in the edit box with CString FileName; MyEditCOntrol.GetWindowText(&FileName); You can then perform all of the validation on FileName. To verify the edit box wasn't blank: if(!FileName.Getlength()) //handle error here - zero length filename To verify that no illegal filename characters were entered: CString InvalidFilenameChars = ""; // put all invalid filename chars in this string if(FileName.FindOneOf(InvalidFilenameChars) != -1) //handle error here - filename contains invalid character There may be a pre-built MFC way of handling all of this.........