Post: C# help plz
10-08-2012, 04:19 PM #1
Master Ro
I make food
(adsbygoogle = window.adsbygoogle || []).push({}); Hi I know this is the wrong section but I need some urgent help.

I am trying to feed a file to a specific user location and I do not know how

For Example:
    
private void button3_Click(object sender, EventArgs e)
{
// Read the file as one string.
System.IO.StreamReader myFile =
new System.IO.StreamReader("c:/Users/Tim/Desktop/Hi/Step3.txt");
string Step3String = myFile.ReadToEnd();

myFile.Close();

this.displayText.Text += Step3String;


This will make it only read the file off my desktop
How do I make it so the program can read it off of any users's location\

Plz reply quickly Thanks!
10-08-2012, 04:35 PM #2
Originally posted by rothe View Post
Hi I know this is the wrong section but I need some urgent help.

I am trying to feed a file to a specific user location and I do not know how

For Example:
    
private void button3_Click(object sender, EventArgs e)
{
// Read the file as one string.
System.IO.StreamReader myFile =
new System.IO.StreamReader("c:/Users/Tim/Desktop/Hi/Step3.txt");
string Step3String = myFile.ReadToEnd();

myFile.Close();

this.displayText.Text += Step3String;


This will make it only read the file off my desktop
How do I make it so the program can read it off of any users's location\

Plz reply quickly Thanks!


    
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Text File|*.txt";
openFileDialog1.RestoreDirectory = true;

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
CodeBox.LoadFile(openFileDialog1.FileName);
using (myStream)
{

}
}
}
catch (Exception ex)
{
MessageBox.Show("" + ex.Message);
}
}


Make sure you import this
    
using System.IO;
10-08-2012, 04:39 PM #3
Master Ro
I make food
Originally posted by TheUnexpected View Post
    
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Text File|*.txt";
openFileDialog1.RestoreDirectory = true;

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
CodeBox.LoadFile(openFileDialog1.FileName);
using (myStream)
{

}
}
}
catch (Exception ex)
{
MessageBox.Show("" + ex.Message);
}
}


Make sure you import this
    
using System.IO;



I have u on Skype I think...If I don't plz add: rothebeast

Can u go online and we can talk about this?
10-08-2012, 04:54 PM #4
Originally posted by rothe View Post
I have u on Skype I think...If I don't plz add: rothebeast

Can u go online and we can talk about this?


I rarely go on skype. So just PM me on here :p
10-09-2012, 12:54 PM #5
BuC-ShoTz
TeamMvKâ?¢
Get rid of the stream.
    
private void buttonX1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() == DialogResult.OK)
{
string infile = File.ReadAllText(open.FileName);
displayText.Text += infile;
}
}

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo