|
Or better, write it into a new file, so it doesn't mess up Excel and other users?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I can't do that since I need to countinu working on the same file with others.
Taht another thinh I was afried of, that if I'll read and write it will mass up my original file
Thats why I hoped that C# will have a built in function for this.
Thanks for your reply.
|
|
|
|
|
Hi christian,
Thakns for the replay.
I was hopping that C# have a built in function to work with excel and do this instead of me having to read a file with a lot of data (about 7,000 line with 10 column each).
But like I was afried, I might have no other choise other that read the whole file and write it back.
Thanks.
|
|
|
|
|
You will have to rewrite the whole file if you want to change it's contents. You should find quite a few samples through Google (e.g. http://stackoverflow.com/questions/532217/efficient-way-to-delete-a-line-from-a-text-file-c[^]).
Regarding CSV: There's a few frameworks flying around that provide you with an abstract view of a CSV file (there's even a LINQ implementation here on CodeProject). And of course, just retaining the file and ignoring the line in question might be an alternative, too. However, the added functionality most likely comes with a price regarding performance.
Cheers,
Philipp
NetDrives - Open Source Network Share Management
|
|
|
|
|
Hello all,
Thanks for the replies.
As you mantioned - I can not realy delete the first line so what I did at the end was to read the file (file.readAllLines(), As I saw in the answers) and then create it again after discarding the first line.
Not very elegant but work
Thanks again!
roy.
|
|
|
|
|
Your question says you need to read the file. If that is the case, File.ReadAllLines alone should work. Just remove the first line from the array for further processing.
जय हिंद
|
|
|
|
|
For removing lines from a text file, the solution you used is as elegant as your going to get.
|
|
|
|
|
Hi i have a file pdf for to explan dar moprede parametrhaye Array
exampel:
int[] a1=new int[2] {1,2};
a1.{parametr}
pleas
|
|
|
|
|
I"m sorry, but you'll have to ask in English, I have no idea what you're asking. However, if you want to parse a PDF, you need a PDF library for that.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
int param1 = a1[0];
int param2 = a1[1];
if that's not what you wanted to know then you need to specify more clearly.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi all,
I have to backup some files, some with readonly attrib.
Is there an other way to open the files with readonly attribute than to reset the "r" attribute, reading and re-setting the attribute again ?
tnx
Frank
|
|
|
|
|
Yes, write code that only asks for read access, then you won't have any problems. I believe I found recently that some .NET libraries ask for full access even if you ask for read only, so I would try using a different class to do what you want, or just use File.Copy to copy the file to the new location.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Thank you,
no can't use copy due to store the files in a database ...
Frank
|
|
|
|
|
Oh, I didn't get they were going into a DB. Well, then change the code you use to read the file. I think File.ReadAllBytes works fine, but using streams does not work, from memory. It's a bug in the framework, essentially.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: using streams does not work ... It's a bug in the framework, essentially.
I disagree. Creating a Stream from a path, without specifying the intended access, assumes read/write intentions. What else should the framework do?
|
|
|
|
|
Hi, I am trying to start an application from my application, which opens a default file, given it's arguments as follow:
Process prc = new Process();
prc.StartInfo.FileName = "azman.msc";
prc.StartInfo.Arguments = "msxml://" + Environment.CurrentDirectory + "\\AuthorizationStore.xml";
prc.Start();
Note the current curectory is:
CurrentDirectory = C:\Users\Hugo\Documents\Visual Studio 2008\Projects\AzManTest\AzManTest\bin
Which contains spaces. For some or other odd reason, it does not like this ...
If this directory is in such a location that there are no spaces in the Directory name, then this works fine...
Can I replace the spaces of the directory with something ? How can I fix this problem.
Any help would be much appreciated!
|
|
|
|
|
It's not odd, the space is used as a delimiter for arguments. Put the path in quotes to get around this.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
LOL .... thanks ^_^
prc.StartInfo.Arguments = "msxml://" + "\"" + Environment.CurrentDirectory + "\\AuthorizationStore.xml" + "\"";
Is this the way to escape a " character?
|
|
|
|
|
Yes. I believe that single quotes work as well, but that's how you escape double ones.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Good morning everybody,
I would like to know how to show in GridViewColumn of pictures of a table of database.
I explain me fill DataSet has leave a request SQL.
In my DataSet I have a column which contains of of the data of type Varbinary.
I would like to know how to show in GridViewColumn of pictures instead of of the data of type Varbinary.
If you can help me please.
Excuse me I am French my English is bad
|
|
|
|
|
Does this[^] help?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Good morning,
Thanks a lot for your help, I achieved show picture in a column of the gate in Asp. Net.
If I could make the same of example that you had me give in XAML the foot would belong.
Here is my code XAML for the Colourful billing of the column
<gridviewcolumn header="Image" width="100" displaymemberbinding="{Binding Path=MyImage}">
<gridviewcolumn.celltemplate>
<datatemplate>
|
|
|
|
|
Hi,
I'm having trouble to obtain the Roles, and the Operations etc. attached to a specific role.
I have a few operations, and a few roles. I want to Iterate through these roles and obtain the operations linked to these roles.
Now I know how to iterate trough these roles and operations individually ... But I don't know how to obtain the link between the two...
I'm using the AZROLESLib.
string storeAddress = "msxml://" + Environment.CurrentDirectory + "\\AuthorizationStore.xml";
AzAuthorizationStoreClass store;
store = new AzAuthorizationStoreClass();
store.Initialize(0, storeAddress, null);
IAzApplication app = store.OpenApplication("Abatis", null);
for (int i = 1; i <= app.Roles.Count; i++)
{
Microsoft.Interop.Security.AzRoles.IAzRole role =
(Microsoft.Interop.Security.AzRoles.IAzRole)app.Roles[i];
String roleName = role.Name;
}
for (int i = 1; i <= app.Operations.Count; i++)
{
Microsoft.Interop.Security.AzRoles.IAzOperation operation =
(Microsoft.Interop.Security.AzRoles.IAzOperation) app.Operations[i];
try
{
String val = operation.Name.Replace(" ", string.Empty);
}
catch (Exception ex)
{
}
}
I can't find the link ... There is an Operations field if you open the roles as follow:
IAzRole roleVal = app.OpenRole(roleName, null);
roleVal.Operations
But I can't iterate through them.
Any help would be much appreciated!
|
|
|
|
|
bonkers123 wrote: I'm using the AZROLESLib.
You probably need to talk to whoever wrote that library then.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
This is a standard Windows (COM) Library ...
modified on Tuesday, May 5, 2009 5:15 AM
|
|
|
|