Click here to Skip to main content
15,887,471 members
Home / Discussions / C#
   

C#

 
GeneralRe: Split text file by Fixed Length [modified] Pin
yueru30-Apr-09 0:09
yueru30-Apr-09 0:09 
GeneralRe: Split text file by Fixed Length Pin
musefan30-Apr-09 0:36
musefan30-Apr-09 0:36 
GeneralRe: Split text file by Fixed Length Pin
OriginalGriff30-Apr-09 1:33
mveOriginalGriff30-Apr-09 1:33 
AnswerRe: Split text file by Fixed Length Pin
N a v a n e e t h29-Apr-09 21:58
N a v a n e e t h29-Apr-09 21:58 
QuestionRe: Split text file by Fixed Length Pin
yueru29-Apr-09 22:06
yueru29-Apr-09 22:06 
AnswerRe: Split text file by Fixed Length Pin
yueru5-May-09 21:23
yueru5-May-09 21:23 
AnswerRe: Split text file by Fixed Length Pin
Mycroft Holmes29-Apr-09 21:59
professionalMycroft Holmes29-Apr-09 21:59 
AnswerRe: Split text file by Fixed Length Pin
Vasudevan Deepak Kumar29-Apr-09 22:33
Vasudevan Deepak Kumar29-Apr-09 22:33 
Quoting Sean Hederman from
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/b0d4cba1-471a-4260-94c1-fddd4244fa23/[^]

string sourceFileName = @"C:\VS2005 SP1.exe";

string destFileLocation = @"C:\";

int index = 0;

long maxFileSize = 52428800;

byte[] buffer = new byte[65536];

 

using (Stream source = File.OpenRead(sourceFileName))

{

    while (source.Position < source.Length)

    {

        index++;

 

        // Create a new sub File, and read into t

        string newFileName = Path.Combine(destFileLocation, Path.GetFileNameWithoutExtension(sourceFileName));

        newFileName += index.ToString() + Path.GetExtension(sourceFileName);

        using (Stream destination = File.OpenWrite(newFileName))

        {

            while (destination.Position < maxFileSize)

            {

                // Work out how many bytes to read

                int bytes = source.Read(buffer, 0, (int) Math.Min(maxFileSize, buffer.Length));

                destination.Write(buffer, 0, bytes);

 

                // Are we at the end of the file?

                if (bytes < Math.Min(maxFileSize, buffer.Length))

                {

                    break;

                }

            }

        }

    }

}


Vasudevan Deepak Kumar
Personal Homepage
Tech Gossips


The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!




GeneralRe: Split text file by Fixed Length Pin
yueru29-Apr-09 23:24
yueru29-Apr-09 23:24 
AnswerRe: Split text file by Fixed Length Pin
Mbah Dhaim30-Apr-09 3:01
Mbah Dhaim30-Apr-09 3:01 
QuestionQuestion on Web serivce... Pin
Siva Koyi29-Apr-09 21:23
Siva Koyi29-Apr-09 21:23 
AnswerRe: Question on Web serivce... Pin
N a v a n e e t h29-Apr-09 21:56
N a v a n e e t h29-Apr-09 21:56 
GeneralRe: Question on Web serivce... Pin
Siva Koyi29-Apr-09 22:11
Siva Koyi29-Apr-09 22:11 
GeneralRe: Question on Web serivce... Pin
N a v a n e e t h29-Apr-09 23:07
N a v a n e e t h29-Apr-09 23:07 
GeneralRe: Question on Web serivce... Pin
Jabbar_espania30-Apr-09 1:33
Jabbar_espania30-Apr-09 1:33 
AnswerRe: Question on Web serivce... Pin
saanj29-Apr-09 23:47
saanj29-Apr-09 23:47 
Questionthread cpu usage Pin
shefa' isied29-Apr-09 21:07
shefa' isied29-Apr-09 21:07 
AnswerRe: thread cpu usage Pin
Jack Li29-Apr-09 21:21
Jack Li29-Apr-09 21:21 
AnswerRe: thread cpu usage Pin
N a v a n e e t h29-Apr-09 21:52
N a v a n e e t h29-Apr-09 21:52 
QuestionICollectionView Pin
Paw Jershauge29-Apr-09 20:29
Paw Jershauge29-Apr-09 20:29 
AnswerRe: ICollectionView Pin
Jack Li29-Apr-09 21:17
Jack Li29-Apr-09 21:17 
GeneralRe: ICollectionView Pin
Paw Jershauge29-Apr-09 21:41
Paw Jershauge29-Apr-09 21:41 
AnswerRe: ICollectionView Pin
Spunky Coder29-Apr-09 21:58
Spunky Coder29-Apr-09 21:58 
GeneralRe: ICollectionView Pin
Paw Jershauge29-Apr-09 23:28
Paw Jershauge29-Apr-09 23:28 
Questionhow to unbind source control Pin
Maddie from Dartford29-Apr-09 17:12
Maddie from Dartford29-Apr-09 17:12 

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.