Click here to Skip to main content
16,012,166 members
Home / Discussions / C#
   

C#

 
QuestionMethod return type followed by question mark (?) Pin
Member 39190494-Jun-08 6:23
Member 39190494-Jun-08 6:23 
AnswerRe: Method return type followed by question mark (?) Pin
Giorgi Dalakishvili4-Jun-08 6:36
mentorGiorgi Dalakishvili4-Jun-08 6:36 
QuestionRandom Numbers Pin
mrcooll4-Jun-08 5:27
mrcooll4-Jun-08 5:27 
AnswerRe: Random Numbers Pin
Gareth H4-Jun-08 5:29
Gareth H4-Jun-08 5:29 
AnswerRe: Random Numbers Pin
Christian Graus4-Jun-08 6:05
protectorChristian Graus4-Jun-08 6:05 
AnswerRe: Random Numbers Pin
Guffa4-Jun-08 6:47
Guffa4-Jun-08 6:47 
AnswerRe: Random Numbers Pin
CPallini4-Jun-08 9:58
mveCPallini4-Jun-08 9:58 
QuestionProblem in receiving Path as a string Pin
selcuks4-Jun-08 4:00
selcuks4-Jun-08 4:00 
Hello,

First of all thank you for this magnificent web site.

I am new to C# and trying some basics on my own.
As you may know if you try to define a path variable as a string in C# you must use "\\" to indicate backslashes:

i.e.:
string filePath = "C:\\Windows\\Temp\\file.txt";


But what if I should received the path information as a parameter to my main() method?

I have tested it many times in simple applications but I could not open a SaveFileDialog in the specified directory. Please consider the following examples that sets SaveFileDialog.InitialDirectory property.
The operation of the application is simple, just display a SaveFileDialog pointing to the location passed to the Form1:

This one works pretty fine:

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
string initialDirectory = "C:\\Windows\\Temp";
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(initialDirectory ));
}

and Form1 class has the following codes inside:

public partial class Form1 : Form
{
private string initialDirectory;
public Form1(string initialDirectory)
{
this.initialDirectory = initialDirectory;
InitializeComponent();
InitializeSvFDlg();

}

private void InitializeSvFDlg()
{
this.saveFileDialog1.InitialDirectory = this.initialDirectory;
this.saveFileDialog1.ShowDialog();
}
}


--------------------------------------------------------------

I observed that SaveFileDialog does not show the passed directory when I use the following method in main() and start the program from Command Prompt with SvFileDlgShow.exe "C:\\Windows\\Temp" command:


///
/// The main entry point for the application.
///

[STAThread]
static void Main(string[] args)
{
string initialDirectory = args[0];
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(initialDirectory));
}

Form1 class is the same.

--------------------------------------------

But the executable works fine if I use SvFileDlgShow.exe "C:\Windows\Temp" as the start-up command.
Is this the intended operation?


Any help is appreciated.
AnswerRe: Problem in receiving Path as a string Pin
Christian Graus4-Jun-08 4:15
protectorChristian Graus4-Jun-08 4:15 
QuestionErasing Lines with drawing tool Pin
Cozmo234-Jun-08 3:38
Cozmo234-Jun-08 3:38 
AnswerRe: Erasing Lines with drawing tool Pin
leppie4-Jun-08 3:44
leppie4-Jun-08 3:44 
AnswerRe: Erasing Lines with drawing tool Pin
Christian Graus4-Jun-08 3:53
protectorChristian Graus4-Jun-08 3:53 
GeneralRe: Erasing Lines with drawing tool Pin
Cozmo234-Jun-08 4:18
Cozmo234-Jun-08 4:18 
GeneralRe: Erasing Lines with drawing tool Pin
Christian Graus4-Jun-08 4:47
protectorChristian Graus4-Jun-08 4:47 
QuestionSine Wave using GDI+ Pin
vinay_K4-Jun-08 2:55
vinay_K4-Jun-08 2:55 
AnswerRe: Sine Wave using GDI+ Pin
Guffa4-Jun-08 3:00
Guffa4-Jun-08 3:00 
QuestionRe: Sine Wave using GDI+ Pin
vinay_K4-Jun-08 3:10
vinay_K4-Jun-08 3:10 
AnswerRe: Sine Wave using GDI+ Pin
leppie4-Jun-08 3:14
leppie4-Jun-08 3:14 
GeneralRe: Sine Wave using GDI+ Pin
vinay_K4-Jun-08 3:36
vinay_K4-Jun-08 3:36 
GeneralRe: Sine Wave using GDI+ Pin
leppie4-Jun-08 3:42
leppie4-Jun-08 3:42 
GeneralRe: Sine Wave using GDI+ Pin
Alan Balkany4-Jun-08 4:06
Alan Balkany4-Jun-08 4:06 
AnswerRe: Sine Wave using GDI+ Pin
Guffa4-Jun-08 3:28
Guffa4-Jun-08 3:28 
GeneralRe: Sine Wave using GDI+ Pin
vinay_K4-Jun-08 3:44
vinay_K4-Jun-08 3:44 
AnswerRe: Sine Wave using GDI+ Pin
Russell Jones4-Jun-08 5:53
Russell Jones4-Jun-08 5:53 
QuestionPerformance issue when using DLL Import to call C++ function from C# Pin
GalitM4-Jun-08 1:45
GalitM4-Jun-08 1:45 

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.