|
If you knew what sort of system they were using to create the file you might be able to code around that.
New Line info[^]
Possibly the best explanation I have ever seen for what the heck happened with new lines.
|
|
|
|
|
Thanks, yeah I've had a peruse through that link as well - very interesting.
The trouble is the files could come from any system, I've got some files from a UNIX system, but have run the modification functionality on windows file as well.
I, stupidly, thought that it would be a simple thing to do...
"If you can't explain it simply, you don't understand it well enough" ~ Albert Einstein
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." ~ Paul Neal "Red" Adair
Now reading: 'The Third Reich', by Michael Burleigh
|
|
|
|
|
1.21 Gigawatts wrote: The trouble is the files could come from any system, I've got some files from a UNIX system, but have run the modification functionality on windows file as well.
Dear lord I am so sorry.
Good luck.
|
|
|
|
|
Ignoring the issue of byte-order marks, you could try this:
1. Open the file with a StreamReader
2. Read the first line
3. Compare StreamReader.BaseStream.Position with line length
This may be able to distinguish between \n and \r\n but of course doesn't really help if you could have \r.
As an (simpler) alternative, is there some way to make WinMerge ignore line-ending changes?
|
|
|
|
|
Gideon Engelberth wrote: As an (simpler) alternative, is there some way to make WinMerge ignore line-ending changes?
Yeah there is, but it's hiding the problem, rather than finding the solution to it.
I don't want to use the wrong EOL terminator for a UNIX file and then that system not being able to read the file correctly.
But as far as the BaseStream.StreamPosition goes, I hadn't thought of that.
Thanks for the info.
"If you can't explain it simply, you don't understand it well enough" ~ Albert Einstein
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." ~ Paul Neal "Red" Adair
Now reading: 'The Third Reich', by Michael Burleigh
|
|
|
|
|
generally speaking, if you are writing an install program, how would you ensure that a computer has a required installation prerequisite (i.e. MySql)?
in development, i add a reference to a DLL to get the MySQL libraries. in an installation environment, would the install program look for that DLL (through COM for example), or would I need to include the required DLL with the install?
|
|
|
|
|
HI All!
i have a panel on which i am drwaing a image control on the center of panel, now when i zoom the image i am resizing the control's left, top , height and width, now when i get negative left and top values the image gets cropped from top Image gets cropped from the top but the bottom scroll bars appears.. is there any way so that when i set the values of my image control to negative(i.e left and top) still the scroll bars appear for that control!!
Thanks in Advance
Samir
|
|
|
|
|
Hello,
i am very new to C# so please be patient.
i am printing orders in my app.
so i have a button which creates the printjob.
the paper will be written in the Printpage-Event.
now i want to have a function that gets th order-object as a parm
and print it on the paper.
the reason is, that an order must be printed on severall programm modules.
private void btnDruck_Click(object sender, EventArgs e)
{
PrintDocument Druckjob = new PrintDocument();
PrintDialog Druckermenue = new PrintDialog();
PrintPreviewDialog Druckpreview = new PrintPreviewDialog();
Druckjob.DocumentName = "Rechnung";
Druckjob.PrintPage += new PrintPageEventHandler(Druckjob_PrintPage);
Druckpreview.Document = Druckjob;
Druckermenue.Document = Druckjob;
if (Druckermenue.ShowDialog() == DialogResult.OK)
{
Druckjob.Print();
}
Druckjob.PrintPage -= new PrintPageEventHandler(Druckjob_PrintPage);
}
void Druckjob_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
StringFormat lineFmtRight = new StringFormat();
lineFmtRight.Alignment = StringAlignment.Far;
g.PageUnit = GraphicsUnit.Millimeter;
g.Dispose();
}
bye jo
|
|
|
|
|
Can any body tell me with an example, how loose coupling is implemented in c# in a such a way that if a class is implementing some interface and if we change something in that class then consumer class doesn't gets effected and without using interface how all the classes consumer class is changed if we didnot implemen using interface.
|
|
|
|
|
Only if you tell me, with an example, of how high cohesion is implemented in c# so that the module implementing the interface is written so it encapsulates only its own duties an does not effect any of the parameters passed to it.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
|
Can any body tell me with an example, how loose coupling is implemented in c# in a such a way that if a class is implementing some interface and if we change something in that class then consumer class doesn't gets effected and without using interface how all the classes consumer class is changed if we didnot implemen using innterface.
|
|
|
|
|
Hi,
I would like to achieve the following. I want to use c# code in an if statement where if the last 2 digits are equal to "xx". How would I approach this.
I appreciate the feedback, thank you in advance.
suprsnipes
|
|
|
|
|
Hi,
your question isn't very clear. If the variable is an integer, all it takes is if ((var % 100) == x) ... . If the value could be negative, you might need additional code.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
You could try
if(Number.ToString().EndsWith("xx"))
{
}
Although it wont be as efficient as using a mod operator
|
|
|
|
|
Would that even reliably work? I mean:
(quote from MSDN)
The return value is formatted with the general numeric format specifier ("G") and the NumberFormatInfo object for the current culture.
What if under some cultures something other than 0-9 is used, or if they put something at the end, or the middle, or whatever? Do such cultures exist?
I don't know, but using mod sure is a lot safer..
|
|
|
|
|
never convert to string if you don't have to; it is inefficient, creates unnecessary objects, and may be error-prone (e.g. when regional settings may influence it, or when checking for a type match).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
How would I go about finding the nearest number ending in 'xx' to another number?
|
|
|
|
|
two weeks later, and still at it???
how would you do it manually?
in order to round a positive integer A to a new value B such that B%100=C one must:
1. subtract C from A
2. round to a multiple of 100
3. add C
|
|
|
|
|
Hi,
I've a fair amount of knowledge on collections in C#, but most of the collections that I know of in C# are ordered, indexed or key-enumerated collections. I'm curious to know if there are any special collections that would allows us to have more that 2 fields and the corresponding row values? Please post information regarding this, in case you are aware of.
My requirement states that I have a list having following columns - Year#, Quarter#, QuarterStartDate & QuarterEndDate, with multiple rows under this (as shown below). I need to return the Year & Qtr for any given date.
Year# Quarter# QuarterStartDate QuarterEndDate
----- -------- ---------------- --------------
2010 Qtr1 01-01-2010 31-03-2010
2010 Qtr2 01-04-2010 30-06-2010
..... .... .......... ...........
..... .... .......... ...........
At present, I'm storing this data in a datatable and performing my validations. Is there a collection type in which I can store this data and iterate thru?
Appreciate your time and effort.
Thanks
Arut
|
|
|
|
|
You can use a Dictionary .
One way is to declare a Dictionary<YearQuater, Foo>
YearQuater is a class that defines a year and the quater.
You can also do this:
Dictionary <int, Dictionary <string, Foo >>
in this cast the key on the outer dictionary is the year (I'm assuming int ), the one on the innner is the "Quarter" which I'm assuming is a string
In both my suggestions Foo is the class that contains the row information.
The only collection I've had to hand-roll is a [Formal] "Set" ie a collection with only one instance of an element within it.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
Hi,
since 3.5 .NET offers a HashSet<T>[^]
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Thursday, February 18, 2010 7:58 AM
|
|
|
|
|
Pants. And I actually looked for it, which is a worry. It's been missing since day one. Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
Hi,
IMO you should turn a row of data into an instance of a user-defined class, then use a generic List of that type.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi all,
How can i add a TextBox on a form every time a row in a grid is added.The Gridview refreshes every two minutes for additional row and would like to have a text box next to the Row in a grid to leave a note about the data being added. So for each entry on a grid i would like to have a text box automatically created next to the new row on a gridview.So that i can leave some comments about the data being added on the grid.
Here is the Gridview :
<asp:GridView ID="gvResult" runat="server" AllowPaging="True" CellPadding="4"
Height="16px" Width="45px" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<asp:Label runat="server">
NO Message List...
</asp:Label>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="CR_CLI" HeaderText="CR_CLI"
SortExpression="CR_CLI" />
How Can I add a text Box that is Just Blank after each Row on a Grid
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:vp2ConnectionString %>"
SelectCommand="SELECT TOP (10) CR_CLI FROM Call WHERE (CR_CLI LIKE '7%') ORDER BY CR_CLI DESC">
</asp:SqlDataSource>
|
|
|
|