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

C#

 
GeneralRe: Bitmap with alpha channel crashes Bitmap () constructor only under Windows 7 Pin
Pete O'Hanlon8-Mar-12 5:43
mvePete O'Hanlon8-Mar-12 5:43 
GeneralRe: Bitmap with alpha channel crashes Bitmap () constructor only under Windows 7 Pin
Alan Balkany8-Mar-12 5:53
Alan Balkany8-Mar-12 5:53 
GeneralRe: Bitmap with alpha channel crashes Bitmap () constructor only under Windows 7 Pin
Pete O'Hanlon8-Mar-12 6:04
mvePete O'Hanlon8-Mar-12 6:04 
GeneralRe: Bitmap with alpha channel crashes Bitmap () constructor only under Windows 7 Pin
Alan Balkany8-Mar-12 6:30
Alan Balkany8-Mar-12 6:30 
GeneralRe: Bitmap with alpha channel crashes Bitmap () constructor only under Windows 7 Pin
Pete O'Hanlon8-Mar-12 8:00
mvePete O'Hanlon8-Mar-12 8:00 
QuestionLooking for a good (¿free? ¿opensource?) library to deal with DXF format Pin
vValkir8-Mar-12 5:24
vValkir8-Mar-12 5:24 
AnswerMessage Removed Pin
8-Mar-12 6:39
professionalN_tro_P8-Mar-12 6:39 
GeneralRe: Looking for a good (¿free? ¿opensource?) library to deal with DXF format Pin
vValkir8-Mar-12 21:57
vValkir8-Mar-12 21:57 
GeneralRe: Looking for a good (¿free? ¿opensource?) library to deal with DXF format Pin
vValkir9-Mar-12 0:22
vValkir9-Mar-12 0:22 
Questioncomopnent need Pin
MohsenSaleh8-Mar-12 4:47
MohsenSaleh8-Mar-12 4:47 
AnswerRe: comopnent need Pin
Eddy Vluggen8-Mar-12 5:00
professionalEddy Vluggen8-Mar-12 5:00 
AnswerRe: comopnent need Pin
Richard MacCutchan8-Mar-12 5:14
mveRichard MacCutchan8-Mar-12 5:14 
QuestionFilestreaming System.OutofMemoryException Pin
Sharonc78-Mar-12 4:38
Sharonc78-Mar-12 4:38 
AnswerRe: Filestreaming System.OutofMemoryException Pin
Eddy Vluggen8-Mar-12 4:57
professionalEddy Vluggen8-Mar-12 4:57 
AnswerRe: Filestreaming System.OutofMemoryException Pin
Luc Pattyn8-Mar-12 5:16
sitebuilderLuc Pattyn8-Mar-12 5:16 
GeneralRe: Filestreaming System.OutofMemoryException Pin
Sharonc78-Mar-12 9:45
Sharonc78-Mar-12 9:45 
AnswerRe: Filestreaming System.OutofMemoryException Pin
Luc Pattyn8-Mar-12 10:04
sitebuilderLuc Pattyn8-Mar-12 10:04 
GeneralRe: Filestreaming System.OutofMemoryException Pin
jschell9-Mar-12 5:32
jschell9-Mar-12 5:32 
AnswerRe: Filestreaming System.OutofMemoryException Pin
Bernhard Hiller8-Mar-12 22:01
Bernhard Hiller8-Mar-12 22:01 
GeneralRe: Filestreaming System.OutofMemoryException Pin
Sharonc79-Mar-12 3:23
Sharonc79-Mar-12 3:23 
AnswerRe: Filestreaming System.OutofMemoryException Pin
jschell9-Mar-12 5:36
jschell9-Mar-12 5:36 
QuestionSet position in file and read from position Pin
Mc_Topaz8-Mar-12 3:14
Mc_Topaz8-Mar-12 3:14 
AnswerRe: Set position in file and read from position Pin
OriginalGriff8-Mar-12 3:55
mveOriginalGriff8-Mar-12 3:55 
The reason it returns 16 is that that is the length of the file...


BaseStream.Position does not do what you want - you want to use the Seek method combined with the position of the character in the stream. So, there is good news and bad news:
Good news: The position is stored in StreamReader.charPos, and does exactly what you want.
Bad news: It's a private variable.

So, getting it and using it is a bit dodgy - you can do it via reflection, but then your code will rely on an undocumented feature, which could disappear at any time. If you want to go that route, there is an extension method which does it all for you here: http://www.daniweb.com/software-development/csharp/threads/35078/page2[^] The code is about 3/4 of the way down.

Not a good idea, to my mind. Instead, I would use a Binary Reader, and read the data directly, processing the lines for myself:
C#
BinaryReader br = new BinaryReader(File.OpenRead(@"D:\Temp\MyList.txt"));
int recordLength = 16;
for (int i = 0; i < 10; i++)
    {
    Console.WriteLine("{0}: {1} = {2}", i, br.BaseStream.Position, (char) br.ReadByte());
    }
Console.WriteLine();

Gives:
0: 0 = A
1: 1 = B
2: 2 = C
3: 3 = D
4: 4 = E
5: 5 = F
6: 6 = G
7: 7 = H
8: 8 = I
9: 9 = U

Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

AnswerRe: Set position in file and read from position Pin
PIEBALDconsult8-Mar-12 4:02
mvePIEBALDconsult8-Mar-12 4:02 
Questiondatagridview c# Pin
missoby8-Mar-12 3:11
missoby8-Mar-12 3:11 

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.