|
Hi
How i can get some information from file which is separeted by semicore.
For example.
name;age;sex;
i need to put all this into array how to do it?
when i want to read something good just seat and type it
|
|
|
|
|
string text = File.ReadAllText();
string[] array = text .Split(';');
can't get easier than this.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
read all the data from the file and store it in a string. then use the string.split() method of c# to split the array. this will return you array having all the records in it without semicore.
the syntax is
string selectedNode; // to store data from file
char[] splitter = { ';' }; // splitter to be used
string[] machineNode; // array which will contain the data after splitting the //string
machineNode = selectedNode.Split();
now u can use machineNode as any array to retrieve data.
regards
sAqIb
|
|
|
|
|
Hope this helps
Regards
private void _parse(string sourceFile)
{
string[] tokens;
// Check if source file exists
if (File.Exists(sourceFile) == false)
throw new Exception("Source file does not exist");
TextReader TR = File.OpenText(sourceFile);
// Parse file
for (string currentLine = TR.ReadLine(); currentLine != null; currentLine = TR.ReadLine())
{
tokens = currentLine.Split(";".ToCharArray());
}
TR.Close();
}
|
|
|
|
|
Thank's too all of you
when i want to read something good just seat and type it
|
|
|
|
|
I have written a service in C# which does some database stuff. At certain intervals it checks if the Database is still reachable by simply Opening and closing the ODBCConnection object.
It seems however that whenever I open and close the connection the memory used by the process increases (noticed this with windows task manager). This is very unwanted offcourse, since the service I make should run for very long periods of time. I tried creating the ODBCConnection object in a using block, but still the effect is the same. Is this indeed a problem in .NET currently? Am I forgetting a certain action that would dump this memory?
Yesterday I ran this app whole night long, just opening and closing the connection object and this morning I noticed that almost all memory was being used, so I figure that it`s not something that the CLR will clean up.
Please if anybody knows about this problem and any solution give me an answer..
Thanks,
Davy
|
|
|
|
|
Maybe you have to Dispose the object manually... when you don't need your object anymore, try calling the Dispose method or set it to null.
hope this helps.
|
|
|
|
|
Hi
I would like to know how I would go about doing a document counter.
This counter should count how many times a document within a page has been downloaded or has been viwed.
Any help would be greatly appreciated.
C# and SQL
|
|
|
|
|
Hi!
Does anyone know, where i can specify a channel of my sound card to
play a mci-video?
I created a class Media, where i have 2 functions that are neccessary
for playing the movie:
1.) public void Open(string sFileName,System.Windows.Forms.PictureBox
videobox)
{
if(this.Status() == "playing")
this.Close();
sCommand = "open \"" + sFileName + "\" type mpegvideo alias
MediaFile style child parent " + videobox.Handle.ToInt32();
mciSendString(sCommand, null, 0, IntPtr.Zero);
sCommand = "put MediaFile window at 0 0 " + videobox.Width + " "
+videobox.Height;
mciSendString(sCommand, null, 0, IntPtr.Zero);
FileIsOpen = true;
}
2.)
public void Play()
{
if(FileIsOpen)
{
sCommand = "play MediaFile";
if (Repeat)
sCommand += " REPEAT";
mciSendString(sCommand, null, 0, IntPtr.Zero);
timer1.Enabled = true;
}
}
But where can i specify the channel for audio output????
As i said i have a sound card with 4 channels, additionally i have the
on board sound.
I want to play the sound on every channel - but how can i do this???
|
|
|
|
|
I have made a windows service.And write a low level keyboard event in it. But it did not invoke when any key pressed.
May any one tell me How events would be invoke in Windows Service.
|
|
|
|
|
What do you mean by "a low level keyboard event"? Did you write a keyboard hook? What does the code look like? Also, Services run under their own desktop. If all you did was create a form and handle its KeyDown event, it'll never see a single keystroke.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
Is it possible to use DAO (Data Access Objects) with C# code?
I need to edit a Jet database... and DDL SQL is not cutting it.
I've searched the net, and can't find DAO code samples in C#.
Is DAO a dead dog? If so, I can't find much on ADOX for C# either.
thanks,
Ron
|
|
|
|
|
C# supports ADO.Net for any kind of databases. so you can use ADO.Net to access your database.
|
|
|
|
|
Unfortunately, from my research, ADO.NET SQL isn't able to change the column's "Allow Zero Length" property. That is why I'm turning to DAO or ADOX.
Ron
|
|
|
|
|
DAO died a long time ago. Also, the last version of DAO won't work with Access XP and above databases.
You can find the ADOX docs here[^]. There are no C# examples, so you'll be translating the VB6 examples.
Just make sure you have the latest MDAC installed. You'll be adding a COM reference to ADOX. You won't find this stuff in a .NET library anywhere.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks for the info and link Dave!
Half the battle is finding the right direction to follow.
Ron
|
|
|
|
|
Hi
I want to read/write file located in the C:\Windows directory of remote pc. Can anyone suggest me wat are the possible ways and which is the best way to do that.
Regards
sAqIb
|
|
|
|
|
Well if you are looking for a C# solution then you will need a program running on that remote PC that will be able to accept commands(and then operate with that file) over the internet from your PC. Look at remoting (this site has plenty of articles) for ideas how to acomplish that.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Is it possible that i access a file for read/write without a program that is running on the remote pc over the network. (i mean i don't want to access the file with the traditional client/server based programs.)
so any suggestions???
sAqIb
|
|
|
|
|
if it is a local network then you just have to share that file/folder.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
consider the scenario when the folder is not shared. As i have to access a file which is located at C:\Windows, so no one like to access that file over the network. so is there still any possibility?
sAqIb
|
|
|
|
|
Nope. But you could grant access to that file ony to one user so nobody else could access it.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
there must b some way to do that
sAqIb
|
|
|
|
|
I am pretty shure that there isn't. I mean just think for a moment. What if you ware able to mess around with other peoples files over the network. Not a happy place, eh?
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
So long as you have admin permissions to the remote PC, the UNC path to the Windows folder (without any additional shares) would be "\\machineName\C$\Windows\filename". This is what you would use for opening your files.
But this is dependant on your network environment. If the machines are setup in Workgroup mode, you'll probably have problems because the account that your code is running under doesn't have permissions to the remote PC. Each machine maintains its own set of user accounts.
If in a domain environment, this gets much easier, since domain user accounts are common to all machines in the domain.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|