|
Those damn irish, j/k
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
for heavens sake, when a hint is given to you you should at least try it.
Anyway, I also was happy when people helped me with my probs, so here is my suggestion:
private void InitializeStreamReader()
{
System.IO.FileStream fstream = System.IO.File.OpenRead(@"c:\test.dat");
System.IO.StreamReader sreader = new System.IO.StreamReader(fstream);
string[] filecontent = sreader.ReadToEnd().Split('\n');
sreader.Close();
foreach (string contentTemp in filecontent)
{
Console.WriteLine(contentTemp);
}
}
Here is a short explanation what is done in this example:
A Filestream is created
A Streamreader which uses the Filestream
the streamreader reads all the content of the file an splits it by the new lines
(every new line is a new element)
these elements are used in a string array
the streamreader is being closed
and now to the interesting part:
every line in the string array is being displayed via console.writeline
Of course it can be done easier, but I think you´ll like it this way as well
|
|
|
|
|
Ezazel
Thanks a lot. I think I see the "why" ...
|
|
|
|
|
Ive been trying to find an example on how to make a progress bar progress with the copying of a file using the copyTo command. does anyone know how to make it work?
|
|
|
|
|
You won't be able to do a real progress bar with File.Copy because it is synchronous and does not give any feedback as to the overall progress of the operation.
You could easily do this yourself, however. Open the file you want to copy, and create a destination file you want to copy the file to. Read in the source file byte-by-byte, and write those bytes to the destination file. Every few bytes, raise an event indicating the overall progress of the operation. Interested components would simply listen to that event and could update the value of a progress bar if they wanted.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
How would I go about doing this? Im still pretty new to C# and havent learned alot of things yet
|
|
|
|
|
|
Up
I am a chinese I love my country.
|
|
|
|
|
there is a much simpler option. Simply add the reference, Microsoft.VisualBasic dll to your c# references project.
Within the Microsoft.VisualBasic dll is the VB.NET file copy routine which displays a copy progress dialog much like the windows one. Here is an example.
Microsoft.VisualBasic.FileIO.FileSystem.CopyFile("c:\helloworld.txt","c:\temp\helloworld.txt",UIOption.AllDialogs,UICancelOption.DoNothing);
|
|
|
|
|
Hi,
i tried ur way but cought in probs.
i gives me with error
"the type or namespace name 'FileIO' does not exists in the class or namespace 'microsoft.visualbasic' (are you missing ans assembly reference?)"
i have also included the reference in the project of microsoft.visualbasic
dont know wats the prob.
can u help?
Nitin...
|
|
|
|
|
Are you using visual studio 2005? As it works for me under that IDE. Apart from that I cant work out what could be your problem.
|
|
|
|
|
Hi,
thanx for reply.
no i m not using vs2005.
i am using vs2003.
can u help.
thanx
Nitin...
|
|
|
|
|
go buy a copy of visual studio 2005.
|
|
|
|
|
This sounds like a good option, except the progress bar I am using is in the status strip instead of a dialog box
|
|
|
|
|
I am using collections for the first time and can't seem to figure out how to obtain the index of the last entry in the collection.
I am guessing that I could use IndexOf() or LastIndexOf() methods, but not sure what to pass into the method.
Here is the code
public static class NumberProcessing<br />
{<br />
public static void UpdateSpinDataCollection()<br />
{<br />
SpinDataCollection.Add(new SpinData <br />
SpinNumber,<br />
CurrentNumber,<br />
Colour<br />
OddorEven);<br />
<br />
SDCPointer = (short)SpinDataCollection.LastIndexOf();<br />
<br />
MessageBox.Show("SDCPointer:\t" + SDCPointer.ToString());<br />
}<br />
}
Haz
|
|
|
|
|
What's the SpinDataCollection type? a Generic collection? An ArrayList?? What???
I'm on a Fuzzy State: Between 0 an 1
|
|
|
|
|
Sorry, it is a generic collection.
public static List<SpinData> SpinDataCollection = new List<SpinData>();
Haz
|
|
|
|
|
The pointy brackets containing the <spindata> bits have been removed from the code by the editor in my previous reply, not sure how to override that when posting here.
Haz
|
|
|
|
|
haz13 wrote: The pointy brackets containing the bits have been removed from the code by the editor in my previous reply, not sure how to override that when posting here.
Put the following characters together for a "less than" character: < When you post it, it will look like <
For "greater than" character, use the combination >, which will result in >
Alternately, you can check the "Ignore HTML tags in this message (good for code snippets)" checkbox when you go to post, which will ignore HTML symbols such as the "greater than" and "less than" characters.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
No, the editor doesn't remove them. Consider it as html. You can check the little check box to tell it to ignore html tags or you can replace your <'s with <'s and >'s with >'s.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
|
Thank you all
Haz
|
|
|
|
|
I am developing a windows service with Visual Studio 2005 that automates the FTP of files to a remote server. I am wondering if anyone knows of a way I can programatically retrieve the available drive space on the remote server prior to the FTP transfer? I know that I can use the GetResponse method of the FTPWebResponse class to retrieve a status code indicating that there is insufficient space when that occurs, but I would prefer to be proactive.
Thank you...
|
|
|
|
|
As far as I know there is no way to know the free space unless the server has a [realy twisted custom] command fot it.
IE: If you want to store a file you send a "STOR" command. To change the current dir, the command is "CWD". As far as I know there is no "standard" command for get the free space
-- modified at 10:51 Friday 18th August, 2006
I'm on a Fuzzy State: Between 0 an 1
|
|
|
|
|
Ok. So I have a function (below) that edits the contents of a web page (loaded in the WEbBrowser control). It works fine when filling in the values of text fields, checking check boxes, and clicking buttons. But I need it to also be able to select an OPTION from a SELECT box.
Actual HTML from page I'm trying to edit...
====================================
<select name="MM" dir="ltr">
<option value="">month
<option value="1" >1
<option value="2" >2
<option value="3" >3
<option value="4" >4
<option value="5" >5
<option value="6" >6
<option value="7" >7
<option value="8" >8
<option value="9" >9
<option value="10" >10
<option value="11" >11
<option value="12" >12
</select>
====================================
The C# function...
====================================
/// <summary>
/// Edit the web Form contents of WebBrowser.
/// </summary>
/// <param name="fieldName">Name of control to edit in web form.</param>
/// <param name="fValue">Value to place in fieldName control.</param>
/// <param name="click">0=textbox, 1=button, 2=checkbox 3=combobox</param>
public void fillField(string fieldName, string fValue, int type)
{
HTMLDocument myDoc = null;
try
{
myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument)WebBrowser.Document;
HTMLInputElement x = (HTMLInputElement)myDoc.all.item(fieldName, 0);
if (type == 0)
x.value = fValue;
else if (type == 1)
x.click();
else if (type == 2)
x.@checked = true;
else if (type == 3)
{
// ??
}
}
catch
{
}
finally
{
myDoc = null;
}
}
====================================
Any help would be much appreciated!
Scott Clayton
|
|
|
|