Click here to Skip to main content
15,908,020 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to check a string to see if it’s valid for use in creating a file name Pin
Brady Kelly21-Aug-07 7:31
Brady Kelly21-Aug-07 7:31 
AnswerRe: How to check a string to see if it’s valid for use in creating a file name Pin
earlgraham21-Aug-07 10:05
earlgraham21-Aug-07 10:05 
Thanks here is the final code it works perfectly...

bool IsValidFilename(String ^fileName)
{
  if ( String::IsNullOrEmpty( fileName ) == true )
    return false;
  
  array<Char>^ invalidFileChar = System::IO::Path::GetInvalidFileNameChars();

  for each ( Char ^i in invalidFileChar )
  {
    if ( fileName->Contains(String::Format("{0}", i)) )
    {
      String ^tmp = String::Format(L" '{0}'  is invalid in a file name.\n", i);
      System::Windows::Forms::MessageBox::Show(gcnew String(tmp),gcnew String(L"Warning"), 
        MessageBoxButtons::OK);
      return false;
    }
  }

  return true;
}


Programmer
Glenn Earl Graham
Austin, TX

GeneralRe: How to check a string to see if it’s valid for use in creating a file name Pin
PIEBALDconsult21-Aug-07 10:50
mvePIEBALDconsult21-Aug-07 10:50 
GeneralRe: How to check a string to see if it’s valid for use in creating a file name Pin
Luc Pattyn21-Aug-07 12:38
sitebuilderLuc Pattyn21-Aug-07 12:38 
AnswerRe: How to check a string to see if it’s valid for use in creating a file name Pin
PIEBALDconsult21-Aug-07 9:59
mvePIEBALDconsult21-Aug-07 9:59 
GeneralRe: How to check a string to see if it’s valid for use in creating a file name Pin
pbraun21-Aug-07 10:49
pbraun21-Aug-07 10:49 
GeneralRe: How to check a string to see if it’s valid for use in creating a file name Pin
PIEBALDconsult21-Aug-07 11:11
mvePIEBALDconsult21-Aug-07 11:11 
AnswerRe: How to check a string to see if it’s valid for use in creating a file name Pin
PIEBALDconsult21-Aug-07 12:14
mvePIEBALDconsult21-Aug-07 12:14 
GeneralRe: How to check a string to see if it’s valid for use in creating a file name Pin
Brady Kelly21-Aug-07 19:29
Brady Kelly21-Aug-07 19:29 
QuestionWindow like left-menu Pin
Muhammad Nauman Yousuf21-Aug-07 6:59
Muhammad Nauman Yousuf21-Aug-07 6:59 
AnswerRe: Window like left-menu Pin
martin_hughes21-Aug-07 9:26
martin_hughes21-Aug-07 9:26 
GeneralRe: Window like left-menu Pin
Muhammad Nauman Yousuf21-Aug-07 17:55
Muhammad Nauman Yousuf21-Aug-07 17:55 
Questionxml file export leaves web page open?? Pin
Venkatesh.P21-Aug-07 6:57
Venkatesh.P21-Aug-07 6:57 
QuestionHow do i draw a smooth linie [modified] Pin
MarkPhB21-Aug-07 6:29
MarkPhB21-Aug-07 6:29 
AnswerRe: How do i draw a smooth linie Pin
Mark Churchill21-Aug-07 19:04
Mark Churchill21-Aug-07 19:04 
GeneralRe: How do i draw a smooth linie Pin
MarkPhB22-Aug-07 7:01
MarkPhB22-Aug-07 7:01 
QuestionAccessing App.Config file Pin
Sha Sea21-Aug-07 6:24
Sha Sea21-Aug-07 6:24 
AnswerRe: Accessing App.Config file Pin
kubben21-Aug-07 7:43
kubben21-Aug-07 7:43 
GeneralRe: Accessing App.Config file Pin
Sha Sea21-Aug-07 10:29
Sha Sea21-Aug-07 10:29 
QuestionInput text function Pin
AndrusM21-Aug-07 6:18
AndrusM21-Aug-07 6:18 
AnswerRe: Input text function Pin
snorkie21-Aug-07 7:15
professionalsnorkie21-Aug-07 7:15 
QuestionHow to Insert User Control into DataGrid Cell ? Pin
ArunkumarSundaravelu21-Aug-07 6:14
ArunkumarSundaravelu21-Aug-07 6:14 
AnswerRe: How to Insert User Control into DataGrid Cell ? Pin
Hessam Jalali21-Aug-07 9:52
Hessam Jalali21-Aug-07 9:52 
GeneralRe: How to Insert User Control into DataGrid Cell ? Pin
ArunkumarSundaravelu22-Aug-07 4:11
ArunkumarSundaravelu22-Aug-07 4:11 
QuestionBindingList based on array Pin
AndrusM21-Aug-07 6:12
AndrusM21-Aug-07 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.