Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to recognize a string's colour Pin
S. Senthil Kumar4-Nov-05 21:33
S. Senthil Kumar4-Nov-05 21:33 
QuestionHow to get started developing a control Pin
BambooMoon4-Nov-05 6:52
BambooMoon4-Nov-05 6:52 
QuestionHow to check object==null for objects without Constructor? Pin
artisticcheese4-Nov-05 6:05
artisticcheese4-Nov-05 6:05 
AnswerRe: How to check object==null for objects without Constructor? Pin
whizzs4-Nov-05 7:27
whizzs4-Nov-05 7:27 
QuestionLoading Files Pin
zaboboa4-Nov-05 5:53
zaboboa4-Nov-05 5:53 
AnswerRe: Loading Files Pin
User 66584-Nov-05 7:32
User 66584-Nov-05 7:32 
GeneralRe: Loading Files Pin
zaboboa4-Nov-05 8:13
zaboboa4-Nov-05 8:13 
AnswerRe: Loading Files Pin
whizzs4-Nov-05 7:37
whizzs4-Nov-05 7:37 
zaboboa wrote:
Hello,

I am loading a file within my app and the way I am refering to it is something like that:


this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf");

However if I want to deploy the application on some other machine, obviously the file will not be there. So, if I want to include the file in my application how do I refer to the file then?

Thank you.


Is the file something you will deploy with your code? If so you will know where it should be. You could try something like this:

try 
{
  this.richTextBox1.LoadFile("c:\\tmp\\Document.rtf");  //of course point to where you think it is
}
catch
{
  OpenFileDialog ofd = new OpenFileDialog();
  ofd.Title = "Please locate Document.rtf";  //or whatever title you want
  ofd.Filter = "RTF File|*.rft";
  ofd.ShowDialog();

  if ( ofd.FileName != "" ) { this.richTextBox1.LoadFile( ofd.FileName ); }
  else { // do something to handle the error }
}

AnswerRe: Loading Files Pin
Jon Rista4-Nov-05 16:16
Jon Rista4-Nov-05 16:16 
Questionget GC to collect unused memory Pin
Stefan Fohringer4-Nov-05 5:06
Stefan Fohringer4-Nov-05 5:06 
AnswerRe: get GC to collect unused memory Pin
Dan Neely4-Nov-05 5:32
Dan Neely4-Nov-05 5:32 
AnswerRe: get GC to collect unused memory Pin
Dave Kreskowiak4-Nov-05 5:52
mveDave Kreskowiak4-Nov-05 5:52 
GeneralRe: get GC to collect unused memory Pin
Jon Rista4-Nov-05 16:33
Jon Rista4-Nov-05 16:33 
GeneralRe: get GC to collect unused memory Pin
Dave Kreskowiak5-Nov-05 2:49
mveDave Kreskowiak5-Nov-05 2:49 
GeneralRe: get GC to collect unused memory Pin
Jon Rista5-Nov-05 9:57
Jon Rista5-Nov-05 9:57 
QuestionMost elegant way to query 400 computers in C#? Pin
artisticcheese4-Nov-05 4:44
artisticcheese4-Nov-05 4:44 
AnswerRe: Most elegant way to query 400 computers in C#? Pin
Rob Graham4-Nov-05 5:14
Rob Graham4-Nov-05 5:14 
GeneralRe: Most elegant way to query 400 computers in C#? Pin
artisticcheese4-Nov-05 5:17
artisticcheese4-Nov-05 5:17 
AnswerRe: Most elegant way to query 400 computers in C#? Pin
S. Senthil Kumar4-Nov-05 21:39
S. Senthil Kumar4-Nov-05 21:39 
GeneralRe: Most elegant way to query 400 computers in C#? Pin
artisticcheese5-Nov-05 2:31
artisticcheese5-Nov-05 2:31 
GeneralRe: Most elegant way to query 400 computers in C#? Pin
S. Senthil Kumar5-Nov-05 3:17
S. Senthil Kumar5-Nov-05 3:17 
QuestionRemoting - recovering communication Pin
duff794-Nov-05 4:37
duff794-Nov-05 4:37 
QuestionAny good C# 2.0 books out yet? Pin
Ed K4-Nov-05 3:46
Ed K4-Nov-05 3:46 
QuestionUnTrapping of Mouse Events Pin
wheelerbarry4-Nov-05 3:38
wheelerbarry4-Nov-05 3:38 
AnswerRe: UnTrapping of Mouse Events Pin
Dave Kreskowiak4-Nov-05 5:47
mveDave Kreskowiak4-Nov-05 5:47 

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.