-3

im implementing this tool that will enable the user to specify a certain excel file that i am parsing and doing some work with ... (Windows form application .net C#) i want to save, the file that the user is choosing(locally) using the openfiledialoge, automatically in a certain directory where the .exe file exists example ../excelfiles/

N Jay
  • 1,774
  • 1
  • 17
  • 36
  • It would be confusing to your user to show an open file dialog and then save the file to a different location. If you need to ask for the filename only, use a simple dialog with a textbox instead. – Ozgur Ozcitak Aug 18 '11 at 09:45
  • I'm a bit confused by the mentions of open dialog and saving. I *think* what you're saying is that you're going to copy the file they've selected to another location. Is that correct? If so, why do you need to copy the file, and more importantly, what obstacle are you encountering that led to you posting this question. It's not currently obvious. – Damien_The_Unbeliever Aug 18 '11 at 10:34
  • -1: Please take a step back and consider that people here want to try and help you. Is your question complete and can the issue be understood by someone who does not have all the information available to you? Unfortunately for the question you have posted the answer is no. Please consider revising your question. – bic Aug 19 '11 at 00:51
  • wow wow wow !!! wats no clear about it LarsTech got what i needed exactly... when im parsing an excel file and saving it to the database i wanna automatically save the sourcefile and keep track of these records.... – N Jay Aug 22 '11 at 06:00
  • bic !! my apologies i think its a bit more clear now thanks... – N Jay Aug 22 '11 at 06:02

1 Answers1

0

You don't offer enough details, but I'm guessing your are trying to do something like this:

using (OpenFileDialog ofd = new OpenFileDialog())
{
  if (ofd.ShowDialog() == DialogResult.OK)
  {
    string parseResults = ParseThisFile(ofd.FileName);
    File.WriteAllText(Path.GetDirectoryName(Application.ExecutablePath) +
                                            @"\excelfiles\" +
                                            Path.GetFileName(ofd.FileName),
                      parseResults);
  }
}

Note: no error checking.

Also, it probably isn't a good idea to save these parsed files in a subdirectory of the executable. You probably want to use Environment.SpecialFolder.etc for that.

LarsTech
  • 80,625
  • 14
  • 153
  • 225