0

I've created a word document generator in C sharp and I want that generated word document to be save in a specific place in the client. I'm looking for a similar functionality like FolderBrowserDialog in Windows Form. I'm using ASP.Net and I tried may solutions but still no luck. Anyone can help me.

1
  • the browser natively doesn't have anything to that effect. You'd need some flash or a Java applet to achieve this. Commented Sep 21, 2011 at 6:42

3 Answers 3

1

No! server (web-app) program don't have an ability to save a generated document at specific place at client.

Sign up to request clarification or add additional context in comments.

2 Comments

ok, what i mean is this, I'm using Microsoft Word 12.0 Object Library to create word document in C# after the creation of that document i want that to be save in the client machine. I'm thinking of the user will browse a location to his machine then click generate button..
@Rob - You may send the "generated" doc to the browser by adding a link referencing that doc or write code to download.
0

try to use the HttpResponse in behind's code:

like:

// Clear the content of the response
Response.ClearContent();    

// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + savedNameWithExtension);

// Add the file size into the response header
Response.AddHeader("Content-Length", myfile.Length.ToString());

// Set the ContentType
Response.ContentType = ReturnExtension(myfile.Extension.ToLower());

// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(myfile.FullName);

// End the response
Response.End();

This section of code will prompt the user to save the specified file on a certain location on his machine.

Hope this is clear.

3 Comments

What control can i use to get the path/directory to save the document.
sorry for late reply, U dont have to use any control here, the provided code will pop up if u wanna save or cancel, if save another window pops up to specify the folder path where u wanna save
thanks.. now i know.. i already got what i want thank boomer.. (thumbsup)
0

When you download a file from the browser its the browser to show the save file dialog and this works on all browsers and on all platforms. Just keep the default behavior and let users decide location and file name. I guess any hacky implementation of that part if possible at all, it is likely to break in some browsers or platforms, like mac, ipad, android...

you do not need to specify any control to be used, once you call the methods to download a file like

Response.WriteFile or Response.BinaryWrite or any other, the browser takes care of everything else for you and let it be like that ;-)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.