|
I was able execute the code you gave with no errors, file was created and contained the expected text.
Try putting sw.Close(); after sw.Flush() and see if that has any effect.
Try debuging the project to identify which line causes the problem- use "step over"(F10) and "step into"(F11), found under the debug menu in Visual studio.
Sorry this isn't much help, maybe the problem lies somewhere else- OS related maybe?
|
|
|
|
|
As Humpo said the code works fine here.
The error you stated doesn't help us, that error message is just saying some error happened. You should see something that says 'BlahBlahException'; that is the part we need to know so we know what error occured.
James
|
|
|
|
|
Sorry, using the command line compiler... thanks anyways for the help though.
I'll keep plowing through it.
|
|
|
|
|
Well i fixed it, Im not sure how- but i did.
Could you guys tell me how to move the file pointer around? My only real programming experience before this has been php. I know a open file has a internal pointer of some sort, i just dont know how to access it with c#.
Thanks
|
|
|
|
|
Think this is what you are looking for
FileStream objects support random access to files using the Seek method. The Seek method allows the read/write position to be moved to any position within the file.
here's an example of using seek to move to the last 128 bytes of a file...
System.IO.FileStream istream = theFile.Open(FileMode.Open);
long fileLength = istream.Length;
if(fileLength > MP3_LENGTH)
{
byte[] ba = new byte[MP3_LENGTH];
istream.Seek(fileLength-MP3_LENGTH, SeekOrigin.Begin);
istream.Read(ba, 0 , MP3_LENGTH);
GetFields(ba);
}
No doubt, as with all my code, there is a more efficient way
|
|
|
|
|
I would like to know what C# is, its not c++, ive worked that out, looks to me like a cross between c++ and vb.
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I think Microsoft has invented A.I. My computer has a mind of its own!"
|
|
|
|
|
I would classify it as a cross between C++, Java, and VB (C# borrows the VB construct for enumeration).
In the end though, language matters not because it is the .NET class libraries that do all of the work.
James
|
|
|
|
|
|
It'sa basically a reworking of the J++ code, with some code from VB I'd guess and it's purpose in life is to annoy Scott McNeally.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Christian Graus wrote:
it's purpose in life is to annoy Scott McNeally.
I have no problems with that, Java was a thorn in my behind during my time at MTU
In all actuality though; they needed another language to bridge the gap between VB and C++; VBs reputation is far too ruined for anyone to take MS seriously if it was the only language for .NET ("oh look! another toy").
James
|
|
|
|
|
I was looking at the dotNETSend GUI that was posted and is broken. Discussion on it stopped in April. What is up?
Anyone have a working version?
|
|
|
|
|
I need a sorted array data structure in my program and would like to know about the built in support for this in C#.
I looked into the System.Collections class and found a SortedList class, but this one doesn't allow duplicate keys.
If there isn't one, I might have to write one utlizing the IList interface.
Another option was to write a class that contained the ArrayList class and used the BinarySearch() method to maintain a sorted array.
Any comments would be helpful.
|
|
|
|
|
Think this bit of code might do what you’re looking for(sortable list), but I’m new to C# so there is probably a simpler or better way of doing this
//myArrayList is array of FileSystemInfo
myArrayList.Sort(new FileComparer());
public class FileComparer : IComparer
{
public int Compare(object a, object b)
{
FileSystemInfo o1 = (FileSystemInfo)a;
FileSystemInfo o2 = (FileSystemInfo)b;
return o1.Name.CompareTo(o2.Name);
}
}
|
|
|
|
|
Thanks, but this is a method to sort a list. I am looking for a Sorted List data structure. This would keep the list sorted as items are added to the list.
I am actually in the process of writing one.
A signature always reveals a man's character and sometimes even his name.
|
|
|
|
|
Hey,
How can i put a powerpoint presentation in a Windows Form?
I'm using Office XP
Thanks
Vanclei Matheus
Brazil
MSN Msgr - vmatheus@msn.com
|
|
|
|
|
My MainForm will receive a WM_DEVICECHANGE message from system.
I want to handle the message in the application.
And the MessageQueue is unavailable in my system.
I want to do someting when i recieve the message.
how to do?
Thanks for your advice.
|
|
|
|
|
You will need to override the WndProc method:
protected override void WndProc(ref System.Windows.Forms.Message m)
{
<br>
base.WndProc(ref m);
}
Nick Parker
|
|
|
|
|
Hello Friends,
In my application, I am showing Internet Explorers favourites. So, I am able to show all the shortcuts present in Internet Explorer's 'Favourite' Folder.
After clicking on that shortcut, Internet explorer should open.
I'm using System.Diagonostics.Process.Start(url) for this which is working fine.
Now my problem is , how can I get the url of the favourite file clicked, so that I can pass it in Process.Start(url) method.
Has anybody having any idea.
Thanks in Advance.
Pranoti
|
|
|
|
|
what about reading the contents of the file:
this is an example of a file:
[DEFAULT]
BASEURL=http://www.artistasdelanada.org/
[InternetShortcut]
URL=http://www.artistasdelanada.org/
Modified=A0D5D3661CB7C00142
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
how to monitor any directory change that happened in a computer.
for example: wo can get a notice when you create a new directory or delete a directory.
|
|
|
|
|
If you are working with an NT environment you can use the FileSystemWatcher class; just point one at the root of all drives you're interested in and follow the documentation for the proper settings (Filter = "", call WaitForChanged() with proper WatcherChangeTypes, etc).
If you aren't working in a pure NT environment you could take a dirty approach and have a timer scan the directory tree for new/missing directories; since you aren't including files this should take *too* long, but it isn't something I would set to run very often.
HTH,
James
|
|
|
|
|
|
Is there a way to conditionally compile code based on if its a debug or release build? Similar to #ifdef _DEBUG in MFC.
|
|
|
|
|
#if DEBUG should work. I think that one would have been best left as #ifdef myself (considering they left in #define and #undef)
HTH,
James
|
|
|
|
|
I´ve createad a remote class that is registered with singleton access mode, so that all the clients access the same class instance. I´ve set my object lifetime so that the object don´t get destroyed until my hosting app finishes. I´ve connected 3 clients to the remote component so far. My question is: if I start to connect a large number of clients (let´s say 100 or 200) in this singleton-access-object, will remoting maintain the same instance to all my clients or it will create other instances for performance reasons ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
The alcohol is one of the greatest enemys of man, but a man who flee from his enemys is a coward.
|
|
|
|