It lives out of server? Well, if it is so and if you have access to user's environment variables, then take a look on variable USERPROFILE (in batch you can see its content with *echo %userprofile%*) If username is eg littleDevil, then userprofile contains path C:\Documents and Settings\littleDevil I hope this helps :)
2009/6/26 Cerebrus <[email protected]> > > Is this a web (ASP.NET <http://asp.net/>) application ? Seems so because > of the use of > the hyperlink controls. > > As an ASP.NET <http://asp.net/> developer, it is not your prerogative to > decide where a > file will be saved on the user's computer. All you should do is > provide a link to the file on the server and allow the user to save it > in the desired location. The browser will handle the rest. > > On Jun 26, 3:04 am, Myra <[email protected]> wrote: > > hi! I desperately need help.. I did peruse the group to see if i could > > get a clue, but this problem seems like it should be much simpler. I > > am new to .NET and web programming in general and bet this really is a > > dumb question... > > > > I have a .NET C# application. The user fills in some values and a > > file is supposed to be written to their computer. ( The app lives out > > on a server ) > > > > I need to change string imd_dir = "C:\\Inetpub\\wwwroot\\IMD\ > > \send_files\\"; > > to a 'relative path' as this directory structure is not on the user's > > computer. > > > > All i was told was to 'make it a relative path' . It can be any path > > I choose. I suppose having the file written to /My Documents/username/ > > file.txt would be best. > > > > Can someone tell me how to change this hardcoded path to ANYTHING that > > will work? > > > > What happens now is a popup that says: > > "Internet Explorer cannot download MMH2009Q3.TXT from localhost. > > Internet Explorer was not able to open this Internet Site. The > > requested site is either unavailable or cannot be found. Please try > > again later." > > > > My development box does not have the hardcoded path below but neither > > will the user's machines. > > > > i do not know what this line is doing either but i think it might be > > part of the problem: > > hlSendFile.NavigateUrl = "../IMD_MSIS/send_files/" + file_name; > > > > TIA for any advice/comments etc... > > Myra > > > > The code is like this: > > > > string imd_dir = "C:\\Inetpub\\wwwroot\\IMD\\send_files\\"; > > string file_name = "MMH" + report_year.ToString() + "Q" + > > report_quarter.ToString() + ".TXT"; > > > > StreamWriter writer = new StreamWriter(imd_dir + > > file_name,false,System.Text.Encoding.ASCII); > > > > while(dr.Read()) > > { > > if (!dr.IsDBNull(1)) > > { > > rec_line = dr.GetString(1); > > > > writer.WriteLine(rec_line.PadRight(300, ' ')); > > } > > } > > writer.Close(); > > > > hlSendFile.NavigateUrl = "../IMD_MSIS/send_files/" + > file_name; > > } > > else ... // do some other stuff. >
