|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
This may or may not work depending on the version of the .NET framework.
It appears that at least up through .NET 4.5.1, the Position property of a FileStream returned only the information about how far the buffering had read.
namespace ConsoleApplication15
{
class Program
{
static void Main(string[] args)
{
using (System.IO.StreamReader reader = new System.IO.StreamReader(@"..\..\Program.cs"))
{
if (reader.EndOfStream)
return;
System.Console.WriteLine("Stream.Position = {0}", reader.BaseStream.Position);
}
System.Console.ReadLine();
}
}
}
This outputs:
Stream.Position = 455
(But looking at the 4.6.1 source code for FileStream , it appears that it will give the correct Position based on the actual read position.)
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
What you want to do, Read text file Line by line or at once, if you want to read it at once then you can refer a above solution given by OriginalGriff
if you want to read it line by line use below code
using System;
using System.IO;
class Program
{
static void Main()
{
foreach (string line in File.ReadLines("c:\\file.txt"))
{
Console.WriteLine("-- {0}", line);
}
}
}
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
Um...that doesn't read it line by line - it reads them all and processes them line by line in a loop afterwards.
If you want to read line by line you need to loop on StreamReader.ReadLine instead.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Yes, basically it reads it at once but later split it by lines
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
Then ,how can i do it use stream ? line by line? I found Peek() ,but only can read 1 char, i need try read 1 line.
|
|
|
|
|
use below code
const Int32 BufferSize = 128;
using (var fileStream = File.OpenRead(fileName))
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize)) {
String line;
while ((line = streamReader.ReadLine()) != null)
}
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
A stream doesn't know about lines; a line-feed is a character. So, you reed 1 char, until you find a new-line character, then process.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
But you explicitly say "if you want to read it line by line use below code" - which it doesn't do!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I think you're confusing File.ReadLines[^] and File.ReadAllLines[^].
ReadAllLines reads all lines into memory and returns them as an array.
ReadLines returns an iterator that yields each line as it's read.
File.ReadLines is essentially the same as:
using (StreamReader reader = new StreamReader(path))
{
string line;
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
It's not a programming problem, but one of mathematics. Find the mathematical solution; turning that into C# code should be easy.
|
|
|
|
|
The math forums are useless. They ask me to show how I'm solving it haha.
The point of my post is that I don't know how to solve it... otherwise I wouldn't be asking for help lmao
|
|
|
|
|
Sorry, but this is a programming, not a maths, forum. The entire problem is one of applying certain mathematical formulas, which you should be able to find in any decent reference. Converting those calculations into code is the easy part.
|
|
|
|
|
Correct...once I got help with the proper formula converting it was simple. Some coders went through more advanced math and are definitely built for this stuff...I am not one of them...and judging by how difficult it was to find an answer, I'm guessing there aren't many out there either. Still, was fun to figure out.
|
|
|
|
|
This is not a programming problem.
It is Geometry.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
You repeat the first part of Richard's answer almost word by word without adding anything. What's the purpose of this?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Basically, I have just read the question, and not the first answer
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Answer was to convert the 1% line to degree and add or subtract to the angles. The math equation associated with it was y=ax+b, a=tan(theta).
|
|
|
|
|
Hello Brothers
I am Looking for the best GPS tracking Application until now.
I want to make application for students tracking in Our University
please any ideas about how I start ?
if any brothers have Application please show me it
Thank you very much for all the members in code project
Best wishes
Dr. Kasa.
|
|
|
|
|
Dr Kasa wrote: I am Looking for the best GPS tracking Application until now. There is no olympic games for GPS software, so we don't know which 'the best' would be.
Dr Kasa wrote: I want to make application for students tracking in Our University
please any ideas about how I start ? Start by creating a basic application, and finding a cheap GPS you can interface with easily.
Dr Kasa wrote: if any brothers have Application please show me it Perhaps the people[^] could help.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Hi Kasa
I think it depends on what kind of GPS unit ur students are carrying ..and what type application (thick client / thin client) you want write..
in My view rather buying separate GPS device , you make could use of ur students smart phone .. as you might aware that every smart phone contains GPS unit in it.
if you bought GPS unit .. some manufacture provides APIs to integrates GPS unit.
if you decide to use mobile phone GPS unit .. you can think of writing mobile app or webapplication..
for webapp from mobile you can consider to use HTML-5 geolocation (all most all all smart mobile are compatible with HTML-5) .. you can find so many examples HTML-5 geolocation
for mobile application you can find plenthy of examples tracking geolocation for Anddroid and iOS
both type of Applications webapp/mobileapp can do tracking.
I hope this helps , Apologies if did not understand what u need
Cheers
Praveen
|
|
|
|
|
|
Hello, sometimes in programming it without a console application is assembly the compile top it up all the over off the hello world first written sorry for one time the two sentences over top but the problem was encapsulation the "hello world" as is in very standard and common prototype first one to have it:
Using Microsoft.VisualBasic; //very unnatural, not natural english
using System.Windows.Forms;
void MAIN()
{
Console.WriteLine("Hello World"); //works
System.Windows.Forms.WriteLine("Hello World"); //doesn't work
};
Explain in your own words how encapsulation would solve this problem.
|
|
|
|