Solved

c# save a file from an editor in a specific folder and with a specific name without user interaction (winforms)

Posted on 2011-03-18
3
278 Views
Last Modified: 2013-12-17
hi all,

as the title suggests, im trying to save a richtextform as a file in a specific location with a specfic name without user interaction when they click a button

is this possible and can anyone help me out?

Thanks
0
Comment
Question by:awilderbeast
  • 2
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35166744
I believe what you are asking is:
System.IO.File.WriteAllText("C:\path\to\output\file.rtf", this.richTextBox1.RTF);

Open in new window

0
 
LVL 1

Author Comment

by:awilderbeast
ID: 35166769
if the folder does not exist will it create it?
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 35167618
No, I don't believe so. You could create it though:
string folder = "C:\\path\\to\\output";
if (!System.IO.Directory.Exists(folder)) System.IO.Directory.CreateDirectory(folder);
System.IO.File.WriteAllText(folder + "\\file.rtf", this.richTextBox1.RTF);

Open in new window

0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Upgrading my SSIS package in VS 2012 6 91
Reactjs with .NET 3 78
global Variable - 2 functions in powershell 1 22
ASP.NET data base connection 35 42
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question