Click here to Skip to main content
15,921,622 members
Home / Discussions / C#
   

C#

 
GeneralRe: Application.Restart() do not terminate application Pin
Vikram A Punathambekar15-Apr-08 5:49
Vikram A Punathambekar15-Apr-08 5:49 
GeneralRe: Application.Restart() do not terminate application Pin
Ravenet14-Apr-08 22:05
Ravenet14-Apr-08 22:05 
GeneralRe: Application.Restart() do not terminate application Pin
Daniel Grunwald14-Apr-08 22:50
Daniel Grunwald14-Apr-08 22:50 
GeneralRe: Application.Restart() do not terminate application Pin
Maddie from Dartford14-Apr-08 23:54
Maddie from Dartford14-Apr-08 23:54 
QuestionSplit and Email files Pin
mailstorao14-Apr-08 18:55
mailstorao14-Apr-08 18:55 
GeneralRe: Split and Email files Pin
mailstorao14-Apr-08 18:57
mailstorao14-Apr-08 18:57 
GeneralRe: Split and Email files Pin
Vikram A Punathambekar14-Apr-08 19:56
Vikram A Punathambekar14-Apr-08 19:56 
GeneralRe: Split and Email files Pin
mailstorao14-Apr-08 20:36
mailstorao14-Apr-08 20:36 
Sorry for that. But I downloaded the code from codeproject itself. anyway the cs file is pasted below...
public class FileSplitter
{
private static readonly long MAXSEGSIZE = 600 * 1024 * 1024;
private static readonly long MINSEGSIZE = 4096;
private static readonly int MAXBUFSIZE = 10240;
private static readonly int MINBUFSIZE = 4096;
private int m_blockSize = 4096; //arbitrary
private long m_segmentSize = DefaultSize; //in megabytes
//not used ... yet.
private string m_outputPath = string.Empty;

public static readonly long DefaultSize = 2 * 1024 * 1024;
public event ProgressNotifyHandler ProgressNotify;

///
/// Simply splits a file name in the current directory using
/// the original filename as a prefix appending numeric
/// in sequence starting with 0.
///

/// <param name="fileName" />file name to split up
/// <returns>number of segments created
public int SplitFile( string fileName )
{
FileStream fsIn = new FileStream(fileName, FileMode.Open, FileAccess.Read);

string basePath = System.IO.Path.GetDirectoryName(fileName);

int fileSize = (int) fsIn.Length;
int segments = (int) (fileSize / m_segmentSize);
int remainder = (int) (fileSize % m_segmentSize);

if (remainder > 0) segments++;

byte[] buffer = new byte[m_blockSize];

int bytesRead = 0;
try
{
for (int i = 0; i < segments; i++)
{
FileStream fsOut = new FileStream(fileName + "." + i, FileMode.Create,FileAccess.Write);
int blocks = (int) (m_segmentSize / m_blockSize);

for ( int j = 0; j < blocks ; j++)
{
bytesRead = fsIn.Read(buffer, 0, m_blockSize);
fsOut.Write(buffer, 0, bytesRead);
}
fsOut.Close();
OnProgessNotify ( Utilities.GetPercentComplete( i+1 , segments ) );
}

return (int) segments;
}
finally
{
OnProgessNotify( 100 );
if ( fsIn != null ) fsIn.Close();
}
}

///
/// The internal buffer size used - defaults to 4K
///

public int BufferSize
{
get { return m_blockSize;}
set
{
if ( value >= MINBUFSIZE && value <= MAXBUFSIZE)
m_blockSize = value;
if ( value > MAXBUFSIZE )
m_blockSize = MAXBUFSIZE;
if ( value < MINBUFSIZE )
m_blockSize = MINBUFSIZE;
}
}

///
/// Size of output files
///

public long SegmentSize
{
get { return m_segmentSize;}
set
{
if ( value >= MINSEGSIZE && value <= MAXSEGSIZE )
m_segmentSize = value;
if ( value > MAXSEGSIZE )
m_segmentSize = MAXSEGSIZE;
if ( value < MINSEGSIZE )
m_segmentSize = MINSEGSIZE;
}
}

///
/// Output Path where split file will go
/// This is not used
///

private string OutputPath
{
get { return m_outputPath; }
set { m_outputPath = value; }
}



protected virtual void OnProgessNotify( int i)
{
if ( ProgressNotify != null )
{
try
{
ProgressNotify( i );
}
catch //catch & sqaush the exceptions...
{}
}

}


public void TestMethod ()
{
OnProgessNotify( 10 );
}


///
/// Test Method...
///

[STAThread]
static int Main(string[] args)
{
if ( args.Length < 1 || args[0] == null || args[0] == "")
{
Console.WriteLine("Invalid command line;\nNeed filename");
return 1;
}
//int segments = fileSplitter.SplitFile(@"C:\Data\My Videos\Monsters.WMV");
FileSplitter fileSplitter = new FileSplitter();
int segments = fileSplitter.SplitFile ( args[0] );
return 0;
}
}
GeneralRe: Split and Email files Pin
mailstorao14-Apr-08 20:37
mailstorao14-Apr-08 20:37 
GeneralWriteProcessMemory problem [modified] Pin
Xmen Real 14-Apr-08 16:15
professional Xmen Real 14-Apr-08 16:15 
QuestionDisplaying event data in a textbox Pin
gwe12314-Apr-08 15:14
gwe12314-Apr-08 15:14 
GeneralRe: Displaying event data in a textbox Pin
Ravenet14-Apr-08 15:29
Ravenet14-Apr-08 15:29 
GeneralRe: Displaying event data in a textbox Pin
Vikram A Punathambekar14-Apr-08 19:59
Vikram A Punathambekar14-Apr-08 19:59 
Generalset the position for ascii char in richtextbox Pin
kamalesh574314-Apr-08 15:02
kamalesh574314-Apr-08 15:02 
GeneralRe: set the position for ascii char in richtextbox Pin
Xmen Real 14-Apr-08 16:19
professional Xmen Real 14-Apr-08 16:19 
GeneralNeed help on populating a listbox with data from a microsoft Access database Pin
precado99914-Apr-08 14:01
precado99914-Apr-08 14:01 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
Christian Graus14-Apr-08 14:04
protectorChristian Graus14-Apr-08 14:04 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
precado99914-Apr-08 14:18
precado99914-Apr-08 14:18 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
Christian Graus14-Apr-08 14:27
protectorChristian Graus14-Apr-08 14:27 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
precado99914-Apr-08 14:50
precado99914-Apr-08 14:50 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
Christian Graus14-Apr-08 14:59
protectorChristian Graus14-Apr-08 14:59 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
precado99914-Apr-08 15:04
precado99914-Apr-08 15:04 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
Christian Graus14-Apr-08 17:57
protectorChristian Graus14-Apr-08 17:57 
GeneralRe: Need help on populating a listbox with data from a microsoft Access database Pin
Hum Dum14-Apr-08 19:22
Hum Dum14-Apr-08 19:22 
QuestionProcess Console Width Pin
dwrst14-Apr-08 13:37
dwrst14-Apr-08 13:37 

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.