Click here to Skip to main content
15,910,877 members
Home / Discussions / C#
   

C#

 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 2:50
Matjaz-xyz24-Nov-08 2:50 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 2:55
mentorGiorgi Dalakishvili24-Nov-08 2:55 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 3:16
Matjaz-xyz24-Nov-08 3:16 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 4:10
Matjaz-xyz24-Nov-08 4:10 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 4:13
mentorGiorgi Dalakishvili24-Nov-08 4:13 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 6:58
Matjaz-xyz24-Nov-08 6:58 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 7:20
mentorGiorgi Dalakishvili24-Nov-08 7:20 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 19:42
Matjaz-xyz24-Nov-08 19:42 
Goodmorning in a new day.

I've had my files locked, because i was trying to rewrite the same file. Unlocker didnt show anything. Thought i could change the output to the same filename as input.

Ok, fixed this.. but now im trying to get this thing into a loop. I have a listbox with filenames/paths. Looks like this:

for (int c = 0; c < listBox1.Items.Count; c++)
           {
               listBox1.SelectedItem = c;
               int length;
               byte[] bt = new byte[1024];
               FileStream input = new FileStream(listBox1.Text, FileMode.Open);

               FileStream output = new FileStream(listBox1.Text + ".new", FileMode.Create);

               BinaryReader rd = new BinaryReader(input);
               BinaryWriter rw = new BinaryWriter(output);

               rd.Read(bt, 0, 55);

               while (true)
               {
                   length = rd.Read(bt, 0, 1024);
                   if (length == 0) break;
                   rw.Write(bt);
               }
               rd.Close();
               rw.Close();

               input.Close();
               output.Close();
           }


Well, it goes only through the first item (that i manualy selected). Where seems to be the problem? I'm focused at that "break;", but i guess that only breaks while loop? or it also breaks my for loop...
Thanks.

Regards,
Matjaž

GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 20:02
mentorGiorgi Dalakishvili24-Nov-08 20:02 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 20:30
Matjaz-xyz24-Nov-08 20:30 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 20:42
mentorGiorgi Dalakishvili24-Nov-08 20:42 
GeneralRe: A program to delete first n bytes in a file Pin
Matjaz-xyz24-Nov-08 21:24
Matjaz-xyz24-Nov-08 21:24 
GeneralRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili24-Nov-08 21:28
mentorGiorgi Dalakishvili24-Nov-08 21:28 
GeneralRe: A program to delete first n bytes in a file Pin
Member 1519807030-Sep-22 23:31
Member 1519807030-Sep-22 23:31 
AnswerRe: A program to delete first n bytes in a file Pin
Giorgi Dalakishvili23-Nov-08 21:06
mentorGiorgi Dalakishvili23-Nov-08 21:06 
QuestionDisabling Button until thread complete Pin
K V Sekhar23-Nov-08 20:42
K V Sekhar23-Nov-08 20:42 
AnswerRe: Disabling Button until thread complete Pin
N a v a n e e t h23-Nov-08 20:45
N a v a n e e t h23-Nov-08 20:45 
GeneralRe: Disabling Button until thread complete Pin
K V Sekhar23-Nov-08 20:53
K V Sekhar23-Nov-08 20:53 
GeneralRe: Disabling Button until thread complete Pin
N a v a n e e t h23-Nov-08 20:56
N a v a n e e t h23-Nov-08 20:56 
AnswerRe: Disabling Button until thread complete Pin
Stephen Lintott23-Nov-08 20:47
Stephen Lintott23-Nov-08 20:47 
GeneralRe: Disabling Button until thread complete Pin
K V Sekhar23-Nov-08 20:54
K V Sekhar23-Nov-08 20:54 
AnswerRe: Disabling Button until thread complete Pin
Christian Graus23-Nov-08 20:51
protectorChristian Graus23-Nov-08 20:51 
GeneralRe: Disabling Button until thread complete Pin
K V Sekhar23-Nov-08 20:55
K V Sekhar23-Nov-08 20:55 
AnswerRe: Disabling Button until thread complete Pin
Giorgi Dalakishvili23-Nov-08 21:02
mentorGiorgi Dalakishvili23-Nov-08 21:02 
QuestionHow to create stored procedure through c# at runtime? Pin
S a n d y23-Nov-08 20:35
S a n d y23-Nov-08 20:35 

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.