Click here to Skip to main content
15,886,724 members
Home / Discussions / C#
   

C#

 
QuestionLINQ to SQL Pin
Darrall1-Apr-10 7:40
Darrall1-Apr-10 7:40 
AnswerRe: LINQ to SQL Pin
Dan Mos1-Apr-10 8:01
Dan Mos1-Apr-10 8:01 
GeneralRe: LINQ to SQL Pin
Darrall1-Apr-10 8:09
Darrall1-Apr-10 8:09 
GeneralRe: LINQ to SQL Pin
Dan Mos1-Apr-10 11:18
Dan Mos1-Apr-10 11:18 
GeneralRe: LINQ to SQL Pin
Darrall1-Apr-10 11:54
Darrall1-Apr-10 11:54 
QuestionConsole app: Take arguments as verbatim string aka how do I create a verbatim string list? Pin
bbranded1-Apr-10 6:38
bbranded1-Apr-10 6:38 
AnswerRe: Console app: Take arguments as verbatim string aka how do I create a verbatim string list? [modified] Pin
PIEBALDconsult1-Apr-10 6:45
mvePIEBALDconsult1-Apr-10 6:45 
GeneralRe: Console app: Take arguments as verbatim string aka how do I create a verbatim string list? [modified] Pin
bbranded1-Apr-10 7:20
bbranded1-Apr-10 7:20 
The following are the command line arguments:
/path:"c:\Documents and Settings\mbrown\Desktop\securable.exe" /save:"c:\Documents and Settings\mbrown\Desktop\"

The following code:

try
                    {
                        Console.WriteLine(savepath + "~scrublbdy.tmp");
                        streamer = File.CreateText(savepath + "~scrublbdy.tmp");
                        streamer.WriteLine("All work and no play makes Jack a null toy.");
                        streamer.Close();

                        File.Delete(savepath + "~scrublbdy.tmp");

                    }
                    catch (Exception err)
                    {
                        Console.WriteLine(err);
                        Environment.Exit(1);

                    }

Produces the following error:

C:\Documents and Settings\mbrown\My Documents\Visual Studio 2008\Projects\securable_buddy\Securable_Buddy\Securable_Budd
y\bin\Release\Securable_Buddy.exe /path:"c:\Documents and Settings\mbrown\Desktop\securable.exe" /save:"c:\Documents and Settings\"

c:\Documents and Settings"\~scrublbdy.tmp
System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path)
   at System.IO.Path.GetFileName(String path)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileO
ptions options)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamWriter..ctor(String path, Boolean append)
   at System.IO.File.CreateText(String path)
   at Securable_Buddy.Program.HandleArgs(String[] args) in C:\Documents and Settings\mbrown\My Documents\Visual Studio 2
008\Projects\securable_buddy\Securable_Buddy\Securable_Buddy\Program.cs:line 117




Note c:\Documents and Settings"\~scrublbdy.tmp.

The trailing \ is being treated as an escape character in the argument. So the "best" solution I can think of is making the arguments that are passed to the main() function be verbatim strings.

Any idea how to modify the incoming args to the Main() function static void Main(string[] args) to make them literal?


Thanks,

Matt
GeneralRe: Console app: Take arguments as verbatim string aka how do I create a verbatim string list? Pin
Daniel Grunwald1-Apr-10 7:35
Daniel Grunwald1-Apr-10 7:35 
GeneralRe: Console app: Take arguments as verbatim string aka how do I create a verbatim string list? Pin
bbranded1-Apr-10 7:42
bbranded1-Apr-10 7:42 
AnswerRe: Console app: Take arguments as verbatim string aka how do I create a verbatim string list? Pin
PIEBALDconsult1-Apr-10 13:39
mvePIEBALDconsult1-Apr-10 13:39 
QuestionRe: Calling an event to a class in a different namespace Pin
roman_s1-Apr-10 5:50
roman_s1-Apr-10 5:50 
AnswerRe: Calling an event to a class in a different namespace Pin
Ghydo1-Apr-10 6:20
Ghydo1-Apr-10 6:20 
AnswerRe: Calling an event to a class in a different namespace Pin
Not Active1-Apr-10 6:37
mentorNot Active1-Apr-10 6:37 
QuestionError loading XML data Pin
billy_iii1-Apr-10 3:23
billy_iii1-Apr-10 3:23 
AnswerRe: Error loading XML data Pin
Garry J Evans1-Apr-10 6:19
Garry J Evans1-Apr-10 6:19 
GeneralRe: Error loading XML data Pin
billy_iii6-Apr-10 1:43
billy_iii6-Apr-10 1:43 
GeneralRe: Error loading XML data Pin
Garry J Evans6-Apr-10 2:54
Garry J Evans6-Apr-10 2:54 
QuestionDo I need to Dispose LINQ To SQL Data Context ? Pin
Nadia Monalisa1-Apr-10 1:35
Nadia Monalisa1-Apr-10 1:35 
AnswerRe: Do I need to Dispose LINQ To SQL Data Context ? Pin
R. Giskard Reventlov1-Apr-10 1:41
R. Giskard Reventlov1-Apr-10 1:41 
GeneralRe: Do I need to Dispose LINQ To SQL Data Context ? Pin
Nadia Monalisa1-Apr-10 7:22
Nadia Monalisa1-Apr-10 7:22 
AnswerRe: Do I need to Dispose LINQ To SQL Data Context ? Pin
Not Active1-Apr-10 1:46
mentorNot Active1-Apr-10 1:46 
GeneralRe: Do I need to Dispose LINQ To SQL Data Context ? [modified] Pin
Nadia Monalisa1-Apr-10 7:14
Nadia Monalisa1-Apr-10 7:14 
GeneralRe: Do I need to Dispose LINQ To SQL Data Context ? Pin
Not Active1-Apr-10 7:34
mentorNot Active1-Apr-10 7:34 
GeneralRe: Do I need to Dispose LINQ To SQL Data Context ? Pin
Nadia Monalisa1-Apr-10 8:00
Nadia Monalisa1-Apr-10 8:00 

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.