Click here to Skip to main content
15,891,567 members
Home / Discussions / C#
   

C#

 
AnswerRe: Convert HTML to RTF Pin
Alan Balkany15-Jul-09 3:51
Alan Balkany15-Jul-09 3:51 
GeneralRe: Convert HTML to RTF Pin
Nagy Vilmos15-Jul-09 3:54
professionalNagy Vilmos15-Jul-09 3:54 
GeneralRe: Convert HTML to RTF Pin
Sebastian T Xavier15-Jul-09 4:02
Sebastian T Xavier15-Jul-09 4:02 
GeneralRe: Convert HTML to RTF Pin
Nagy Vilmos15-Jul-09 4:11
professionalNagy Vilmos15-Jul-09 4:11 
GeneralRe: Convert HTML to RTF Pin
Sebastian T Xavier15-Jul-09 4:23
Sebastian T Xavier15-Jul-09 4:23 
GeneralRe: Convert HTML to RTF Pin
Luc Pattyn15-Jul-09 4:11
sitebuilderLuc Pattyn15-Jul-09 4:11 
GeneralRe: Convert HTML to RTF Pin
Dave Kreskowiak15-Jul-09 5:20
mveDave Kreskowiak15-Jul-09 5:20 
GeneralRe: Convert HTML to RTF Pin
Luc Pattyn15-Jul-09 5:35
sitebuilderLuc Pattyn15-Jul-09 5:35 
GeneralRe: Convert HTML to RTF Pin
Dave Kreskowiak15-Jul-09 7:29
mveDave Kreskowiak15-Jul-09 7:29 
GeneralRe: Convert HTML to RTF Pin
Luc Pattyn15-Jul-09 7:36
sitebuilderLuc Pattyn15-Jul-09 7:36 
AnswerRe: Convert HTML to RTF Pin
V.15-Jul-09 4:09
professionalV.15-Jul-09 4:09 
QuestionStarting to read a file from an origin with Binaryreader Pin
SimpleData15-Jul-09 3:33
SimpleData15-Jul-09 3:33 
AnswerRe: Starting to read a file from an origin with Binaryreader Pin
Luc Pattyn15-Jul-09 3:41
sitebuilderLuc Pattyn15-Jul-09 3:41 
AnswerRe: Starting to read a file from an origin with Binaryreader Pin
Ennis Ray Lynch, Jr.15-Jul-09 3:45
Ennis Ray Lynch, Jr.15-Jul-09 3:45 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
SimpleData15-Jul-09 4:05
SimpleData15-Jul-09 4:05 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
Ennis Ray Lynch, Jr.15-Jul-09 4:11
Ennis Ray Lynch, Jr.15-Jul-09 4:11 
AnswerRe: Starting to read a file from an origin with Binaryreader Pin
OriginalGriff15-Jul-09 4:04
mveOriginalGriff15-Jul-09 4:04 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
SimpleData15-Jul-09 4:13
SimpleData15-Jul-09 4:13 
AnswerRe: Starting to read a file from an origin with Binaryreader Pin
OriginalGriff15-Jul-09 4:33
mveOriginalGriff15-Jul-09 4:33 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
SimpleData15-Jul-09 4:44
SimpleData15-Jul-09 4:44 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
Luc Pattyn15-Jul-09 4:54
sitebuilderLuc Pattyn15-Jul-09 4:54 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
OriginalGriff15-Jul-09 4:59
mveOriginalGriff15-Jul-09 4:59 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
SimpleData15-Jul-09 4:52
SimpleData15-Jul-09 4:52 
I write the data to the end of file with this code:

public bool AppendToBinary(string File, string strToAppend)
        {
            FileStream fs = null;
            BinaryWriter bw = null;

            try { fs = new FileStream(File, FileMode.Open, FileAccess.ReadWrite); }
            catch { throw new Exception("Dosya akışı oluşturulurken hata oluştu."); }

            try { bw = new BinaryWriter(fs); }
            catch { throw new Exception("Binary okuyucu oluşturulurken hata oluştu."); }

            try
            {
                bw.Seek(0, SeekOrigin.End);
                bw.Write(strToAppend);
            }
            catch { throw new Exception("Dosyaya yazılırken hata oluştu."); }
            finally { bw.Close(); fs.Close(); fs.Dispose(); }

            return true;
        }


I get the location of the desired string in file with this code:
public long DigBinary(string File, string strToDig)
{
    FileStream fs = null;

    try { fs = new FileStream(File, FileMode.Open, FileAccess.Read); }
    catch { throw new Exception("Dosya akışı oluşturulamadı."); }

    try
    {
        byte[] icerik = new byte[fs.Length];
        fs.Read(icerik, 0, (int)fs.Length);

        string asText = Encoding.UTF8.GetString(icerik);
        int index = asText.IndexOf(strToDig);

        if (index == -1)
            return -1;

        if (strToDig != asText.Substring(index, strToDig.Length))
            return -2;

        return index;
    }
    catch { throw new Exception("Dosya okunurken hata oluştu."); }
    finally { fs.Close(); fs.Dispose(); }
}


I try to read data from the desired location of file to the end with this method: But it doesn't work...
public string ReadBinary(string File, long origin)
        {
            FileStream fs = null;

            try { fs = new FileStream(File, FileMode.Open, FileAccess.Read); }
            catch { throw new Exception("Dosya akışı oluşturulamadı."); }
            StringBuilder sb = new StringBuilder();
            try
            {
                if (fs.CanSeek)
                {
                    fs.Seek(origin, 0);
                    byte[] buffer = new byte[fs.Length];
                    fs.Read(buffer, 0, (int)fs.Length);

                    foreach (byte b in buffer)
                    {
                        try
                        {
                            sb.Append((char)b);
                        }
                        catch { };
                    }
                    MessageBox.Show(sb.ToString());
                }

                return sb.ToString();
            }
            catch { throw new Exception("Dosya okunurken hata oluştu."); }
            finally { fs.Close(); fs.Dispose(); }
        }

GeneralRe: Starting to read a file from an origin with Binaryreader Pin
OriginalGriff15-Jul-09 5:03
mveOriginalGriff15-Jul-09 5:03 
GeneralRe: Starting to read a file from an origin with Binaryreader Pin
SimpleData15-Jul-09 5:08
SimpleData15-Jul-09 5:08 

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.