Click here to Skip to main content
15,894,955 members
Home / Discussions / C#
   

C#

 
AnswerRe: text file > Binary and Binary > Text file Pin
Ravi Sant17-Feb-11 1:15
Ravi Sant17-Feb-11 1:15 
GeneralRe: text file > Binary and Binary > Text file Pin
grmihel217-Feb-11 1:26
grmihel217-Feb-11 1:26 
AnswerRe: text file > Binary and Binary > Text file Pin
Richard MacCutchan17-Feb-11 1:15
mveRichard MacCutchan17-Feb-11 1:15 
GeneralRe: text file > Binary and Binary > Text file Pin
grmihel217-Feb-11 1:22
grmihel217-Feb-11 1:22 
GeneralRe: text file > Binary and Binary > Text file Pin
Richard MacCutchan17-Feb-11 1:46
mveRichard MacCutchan17-Feb-11 1:46 
GeneralRe: text file > Binary and Binary > Text file Pin
grmihel217-Feb-11 4:07
grmihel217-Feb-11 4:07 
GeneralRe: text file > Binary and Binary > Text file Pin
Richard MacCutchan17-Feb-11 4:24
mveRichard MacCutchan17-Feb-11 4:24 
GeneralRe: text file > Binary and Binary > Text file Pin
grmihel217-Feb-11 4:28
grmihel217-Feb-11 4:28 
Oh yes, sorry, the WriteFile function is following:

public byte[] WriteFile(string filePath, StoredFile file)
{
	byte[] buffer = file.FilContent.ToArray();
        FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
        try
        {
        	int length = (int)fileStream.Length;  // get file length
                buffer = new byte[length];            // create buffer
                int count;                            // actual number of bytes read
                int sum = 0;                          // total number of bytes read

                // read until Read method returns 0 (end of the stream has been reached)
                while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
                    sum += count;  // sum is a buffer offset for next reading
        }
        finally
        {
	        fileStream.Close();
        }

        return buffer;
}

GeneralRe: text file > Binary and Binary > Text file Pin
Richard MacCutchan17-Feb-11 4:33
mveRichard MacCutchan17-Feb-11 4:33 
GeneralRe: text file > Binary and Binary > Text file Pin
grmihel218-Feb-11 0:14
grmihel218-Feb-11 0:14 
GeneralRe: text file > Binary and Binary > Text file Pin
Richard MacCutchan18-Feb-11 1:36
mveRichard MacCutchan18-Feb-11 1:36 
GeneralRe: text file > Binary and Binary > Text file Pin
grmihel218-Feb-11 2:12
grmihel218-Feb-11 2:12 
GeneralRe: text file > Binary and Binary > Text file Pin
Richard MacCutchan18-Feb-11 2:45
mveRichard MacCutchan18-Feb-11 2:45 
QuestionDo I need to store my database in Application Data folder instead of Application.StartUp folder Pin
Nadia Monalisa16-Feb-11 22:35
Nadia Monalisa16-Feb-11 22:35 
AnswerRe: Do I need to store my database in Application Data folder instead of Application.StartUp folder Pin
Bernhard Hiller16-Feb-11 22:51
Bernhard Hiller16-Feb-11 22:51 
AnswerRe: Do I need to store my database in Application Data folder instead of Application.StartUp folder Pin
PIEBALDconsult17-Feb-11 1:47
mvePIEBALDconsult17-Feb-11 1:47 
QuestionEncryption and descryption using 3DES [modified] Pin
sarang_k16-Feb-11 21:58
sarang_k16-Feb-11 21:58 
AnswerRe: Encryption and descryption using 3DES Pin
OriginalGriff16-Feb-11 22:48
mveOriginalGriff16-Feb-11 22:48 
AnswerRe: Encryption and descryption using 3DES Pin
Bernhard Hiller16-Feb-11 22:56
Bernhard Hiller16-Feb-11 22:56 
AnswerRe: Encryption and descryption using 3DES Pin
RaviRanjanKr21-Feb-11 18:05
professionalRaviRanjanKr21-Feb-11 18:05 
QuestionHow to prevent usage of class libraries shipped with application? Pin
Chesnokov Yuriy16-Feb-11 21:37
professionalChesnokov Yuriy16-Feb-11 21:37 
AnswerRe: How to prevent usage of class libraries shipped with application? Pin
Groulien16-Feb-11 22:58
Groulien16-Feb-11 22:58 
AnswerRe: How to prevent usage of class libraries shipped with application? Pin
Bernhard Hiller16-Feb-11 23:07
Bernhard Hiller16-Feb-11 23:07 
AnswerRe: How to prevent usage of class libraries shipped with application? Pin
jschell17-Feb-11 8:27
jschell17-Feb-11 8:27 
QuestionRaise COM Event within C# Pin
califax2k16-Feb-11 21:03
califax2k16-Feb-11 21:03 

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.