|
One more update on this is when I use normal C program to split the files, all of them are received at the destination.
|
|
|
|
|
mailstorao wrote: Any help would be appreciated?
How do you expect people to help you if they can't see what you are doing? Showing the relevant code would go a long way here.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
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;
}
}
|
|
|
|
|
Also, this is happening only for .doc files.
|
|
|
|
|
hello,
im trying to write in process memory(of a game)at a specified address, but its not working, neither any error nor working, im new to API.
here is the code im using to write a int(4 bytes) value at 0xB7CE50.
IntPtr m_hProcess = IntPtr.Zero;
m_hProcess = APIDecalaration.OpenProcess(APIDecalaration.PROCESS_ALL_ACCESS, 1, ((UInt32)MYProcesses[0].Id));
APIDecalaration.WriteProcessMemory(m_hProcess, (IntPtr)0xB7CE50, 1000, 4, 0);
int isClosed = APIDecalaration.CloseHandle(m_hProcess);
if (isClosed == 0)
throw (new Exception("CloseHandle failed"));
APIDecalaration class :
public const int PROCESS_ALL_ACCESS = 0x1F0FFF;
[DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, int bInheritHandle, UInt32 dwProcessId);
[DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, int lpBuffer, long nSize, long lpNumberOfBytesWritten);
[DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int CloseHandle(IntPtr hObject);
where i did mistake ???
edited :
i want to write 1000 in that address, but there is no effect
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
modified on Monday, April 14, 2008 10:31 PM
|
|
|
|
|
I have a C# Form textBox that I would like to display a global counter that keeps track of different events. I would like to lock down the textBox so no input can be entered. Does anyone have an example of how to do this or a example of a better way of displaying this counter.
|
|
|
|
|
Hi
can can, You create a global property for the counter. and create a custom event for every evetn fiare in the any of the ur form trigger ur custom event and update the textbox by the ur counter value.
Basically u create a text box property readonly=true.
|
|
|
|
|
A TextBox has a ReadOnly property which you have to set to false. You could use a Label, but a TextBox is better because it still allows the user to copy-paste the contents.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
Hi all,
i need set the position for ascii char in richtextbox.
Here is my coding that will show the ascii char in richtextbox.
string hex = "040";
string hex1 = "025";
string hex2 = "023";
string hex3 = "025";
int code = Convert.ToInt32(hex,16);
int code1 = Convert.ToInt32(hex1,16);
int code2 = Convert.ToInt32(hex2,16);
int code3 = Convert.ToInt32(hex3, 16);
richTextBox1.Text = Encoding.Default.GetString(new byte[] {(byte)code,(byte)code1,(byte)code2,(byte)code3});
Now i need arrange all the ascii char in correct position.I hd tried in many ways,but still got errors.pls help me.
Thank you.
KAMALES
|
|
|
|
|
try in this way :
byte mychar = 40;
richTextBox1.Text = ((char)mychar).ToString();
hope it will help
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
well I need to display the customerID, firstName, and lastName from a table called customers into a listbox. The idea is that I want the user to view what customers are in the database and then pick one to update or delete. Then it will take you to a diffrent form where you can update or delete the customer.
|
|
|
|
|
sounds fun, what have you tried ?
Can't you just set the datasource of the listbox, or do you need to add columns in code ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I don't think I need to add columns in code. I just need a listbox to display an ID number, first name and last name from a table in my database. We have connection to the database. I just need to know how to code the listbox to show these columns of my table.
|
|
|
|
|
Does it have a datasource property ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I do not have a datasource. All I know is that I have a connection to the database and i know the select statement i need to put into the code.
|
|
|
|
|
Then when you call the SQL, you'll have a dataset. Which is a datasource.
So is an array, as it happens.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Can you show me an example of this so I can have a better idea.
|
|
|
|
|
I'm kind of confused. You have SQL, but you don't know how to use it to get info into C# ? Have you done any research ? Is it a SQL Server DB ? Do you know how to create a connection string ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
precado999 wrote: I don't think I need to add columns in code
I think u need to add column the to display the data from the Database.
Set the listview property to details. Then add columns
lyk:- listview.Columns.Add("Heading", width, allignment)
same for another column you want to add.
then create a datatable from database with the data u want, in ur case ID, FName, LName.
Loop thru the rows to show the data.
foreach(DataRow dr in dt.rows)//here dt is for datatable
{
listview.Subitems.Add(dr["ID"].tostring());
//same for Fname,
//& so on.....
}
The code here here is not syntactically correct.
Hope this will help you.
|
|
|
|
|
hello, id like to run console program from C# gui and catch its output and i have a problem that text in console is bigger than standard console width. is there a way how to set console width in C# for that process ?
maybe there is option in process.StartInfo how to use console with bigger width than standard 80 chars?
|
|
|
|
|
Hi,
I don't know you can do that programmatically, but maybe this helps: you can set it
manually by right-clicking the console window title, change window size and buffer size,
then save choosing "save for all windows with same title".
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
thank you for reply
i already found this but it didnt help and it still cuts characters that dont fit in standard width
|
|
|
|
|
dwrst wrote: it still cuts characters
I don't think so. I just ran it with a width of 170 characters, and it works great.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
really? and you launched it as process (external application) and you can read 170 characters per line from it? because it doesnt work for me.. so maybe the problem is in stream reader? im using this code http://www.codeproject.com/KB/threads/launchprocess.aspx
|
|
|
|
|
Hi,
no, sorry, it is a console app that outputs to a wide console it owns.
if the app is an existing app it may have its own limitations, and/or it may assume
its console is 80 char wide.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|