Click here to Skip to main content
15,881,852 members
Home / Discussions / C#
   

C#

 
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 
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 
True, I can see that the Write method didn't make sense Smile | :)
I'm not really used to do these RW files programming, so I'm sorry for newbieness, but you have to learn it some how Smile | :)

Anyways, I have attempted to rewrite another write method like this:
public void WriteFile(string filePath, StoredFile file)
{
    byte[] data = file.FilContent.ToArray();
    FileStream fileStream = new FileStream(@"d:\temp\doctest.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
    try
    {
        int length = (int)data.Length;
        int buffer = 1000;

        fileStream.SetLength(length);
        fileStream.Seek(length - buffer, SeekOrigin.Begin);
        fileStream.Write(data, 0, buffer);
        fileStream.Flush();
    }
    finally
    {
        fileStream.Close();
    }
}


The doctest.docx file is now 14KB as the original, so something seems right. But the file is still somehow corrupted, cuz I can't open the docx without an error message telling me the data in the Word document is wrong... Notice that the file.Filcontent is the varbinary value from the Database.
By the way, is it really so simple, that when I'm sure that its a .docx file I store in my DB as varbinary, I can just store it on local machine as a file with the same extension? No need of creating a Word application object and write it through that?
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 
AnswerRe: Raise COM Event within C# Pin
Bernhard Hiller16-Feb-11 23:14
Bernhard Hiller16-Feb-11 23:14 
QuestionDLL and config file problem Pin
david bagaturia16-Feb-11 20:56
david bagaturia16-Feb-11 20:56 

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.