|
stringFromFile;
char[] delim = new char[1];
delim[0] = ' ';
string[] words = stringFromFile.Split(delim);
foreach(string s in words)
{
//check word
}
hope it helps - sounds strange, that it should replace line breaks with whitespaces
-spif2001
|
|
|
|
|
Thanks. That may help.
This would be even easier: DO you know of any programs that can replace ' ' with line breaks? Word sure can't :/
|
|
|
|
|
You'd have to write it. I don't know of any app that would convert spaces to CRLF's.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
System.IO.StreamReader sr = new System.IO.StreamReader(@"c:\test.txt");<br />
string data = sr.ReadToEnd().Replace(" ", "\r\n");
|
|
|
|
|
ALL PRAISES TO YOU, SEAN MICHAEL MURPHY! That worked _beatifully_. Thank you so much!
|
|
|
|
|
Ok, situation as such...have a collection and it extends collectionbase.
this is how all of my functions go, in their most simple form...all code in (welcoming?) arms of a lock with the intention of making my control threadsafe.
public void Add(string text)
{
lock(List.SyncRoot)
{
List.Add(new SimpleListItem(text));
}
}
When i start adding items to the control with both a thread, and at same time syncheroussly...the control freezes up.
I think at that point its stuck in some kind of race condition because conflicting locks are preventing anything from getting into the collection for infinity and beyond :P
This leads me to my question:
Where do i put lock(List.SyncRoot)? When i comment out that line from my add function the control goes fine...
|
|
|
|
|
You should not alter a control from another thread than it was created in. Read in the MSDN about the Invoke method of the Control class. It delegates calls into the right thread. By doing so you even wont need to synchronize the calls anymore.
|
|
|
|
|
Thx for clearing that up for me.
|
|
|
|
|
I have a program that is run via Task Scheduler as a given user. For sake of argument, we'll call this user "backup".
When my program runs via the Task Scheduler, I have it pop up an input box on a certain event (backup failure) and ask the user (apparently "backup", the user who the task is running as) if he/she would like to retry to the backup.
So lets say the user "bob" is logged on, hell, lets look at the case when bob is logged on as well as when nobody is logged on.
If my task runs and has a problem, the input box is lost due to "backup" not being logged in. Yet it still shows up in my process listing...
So I need a way to have my program (which is running with administrative privileges as they are needed for backup reasons) to log the current user off (or not if nobody is logged on) and log backup on prior to running its backup jobs.
Now I know that this sounds like a hokey thing to do with regards to security. I'm not fond of doing it this way but it is what has been asked of me. To be honest, I plan on implementing a toggle for this functionality.
Thanks...
|
|
|
|
|
Logs the user off?! If an application did that to me unexpectedly, the first thing I'd do is uninstall it, burn the CD's it came on, then mail the molten pile of (*$^##& back to the company that wrote it explaining why.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
haha... no doubt man
again, not my idea, just need to know how to implement it or work around it
any helpful suggestions?
|
|
|
|
|
My thoughts are to simply make this a service and be done with it...
|
|
|
|
|
Well, the normal way to do this would be to run the service under an account that has the appropriate rights to the resource you need and not supply any user interface what-so-ever. If the backup fails, you can't just pop up a dialog because you don't know if there is anyone logged in or not to see it. You can't just log off the current user, then log on some other user either. It would REALLY SUCK if you forced a user off without saving his changes (if he/she wanted them saved). You simply can't control how that is done. You will either have to FORCE the user off, losing any changes he might need saved or site there and wait for the user to save changes. Oh!! There's a problem there. The user can always click Cancel to saving any changes. This will also have the effect of canceling the logoff too!
A better method would be to have a second application running in the system tray that communicates with the service and supplies notifications and interactions through the tray icon (you can use .NET Remoting for communication part.) This application would then put up the interface to ask the user if they would like to retry the backup and tell the service to retry if it needs to.
I would also suggest going back to the people who are requesting this junk and telling them that what they want is not practical and modify the specifications to, God forbid, accomodate the needs of the USER, and works within the functional limits of Windows.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
awesome, excellent advice...
Yeah, here is the deal. I am very new to windows programming. I was brought up in a Linux C++/Java environment and am making my way through the complexities of windows programming. I can say that I am digging it so far...
I have misconstrued what was communicated to me or better yet, I wasn't able to decipher what my contact was attempting to communicate to me. I tell ya, half of being in IT is interpreting just what the hell the client is asking for. lol...
So yes, I completely agree with you and will begin implementing this tonight. I will most likely be back with more questions relating to this.
Thanks a million!
Spacey
|
|
|
|
|
I have a text file that a program automatically generates and saves in a txt file format. When I open the text file the lines of the text file are as follows:
X000754Y-000065I000754J000189
X000950Y000025I000754J000189
I would like to have a way to open the file and have the lines automatically format to:
X000754 Y-000065 I000754 J000189
X000950 Y000025 I000754 J000189
If anybody knows of source code that would format lines of a text file by adding spaces to it I would appreciate the help.
Thanks for your time.
Darren
|
|
|
|
|
A regular expression will do this for you, easy.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
As Christian said Regular Expressions would be the best way, but if you (like me) dont know how to build those here another straightforward solution:
private static string Format(string text)
{
System.Text.StringBuilder b = new System.Text.StringBuilder();
int counter = 0;
for (int i = 0; i < text.Length; i++)
{
b.Append(text[i]);
if (char.IsNumber(text[i]))
{
counter++;
if (counter == 6)
{
b.Append(' ');
counter = 0;
}
}
}
return b.ToString();
}
|
|
|
|
|
Hi,
I must create a kind of presentation program where a computer has a player and has multiple TV attachted to it. I want to see all the data on the television, but it must also be possible to connect other viewing object to see it.
Program is simular to powerpoint only it must be able to have multiple viewers attachted to a pc with the player software.
My question is what stream or simular must I use to write data to??
I think it must use DirectX, but can't find a good example for C# code.
Can anyone help me please,
Thanx,
SquallBlade
|
|
|
|
|
This has nothing to do with programming, and everything to do with your video card. If your card is outputting to the TV, whatever code you write will display to the TV. If your card does not connect to the TV, no amount of code will make it happen.
In other words, get the right video card, and powerpoint will do this for you, no problems.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I ment trying to show something on the second port of a video card. So I want to only see it on display 2 and on display 1 you can't see anything, only Windows.
Greetz,
Squall
|
|
|
|
|
Again, same answer. It has everything to do with your video card and nothin to do with programming. PowerPoint WILL do this. You just need to setup the video card and PowerPoint correctly, something that is beyond the scope of this forum.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I must create my own presentation program and i already found out how to show it on the second monitor. But how do I fade and swipe objects working with Direct3D, because DirectDraw is decapricated.
Greetz
|
|
|
|
|
You mean deprecated? DirectDraw is not deprecated and is even encapsulated in the Managed DirectX 9.0[^] SDK, which you can download and use from within C# or any other managed language.
The documented APIs in the SDK discuss how to use screen objects and to direct video. I urge you to read the SDK first.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Dave is wrong. To display things on the second monitor, there is a static class called Monitors or something that allows you to enumerate all screens. From this, you can get the co-ordinates to draw to in order to get onto the second screen.
just a sec.
The class is called Screen. This code shows a window called secondMonitor on the second screen, or hides it if there isn't one.
Screen [] screens = Screen.AllScreens;
if (screens.GetUpperBound(0) > 0)
{
Screen secondary = screens[1];
secondMonitor.Bounds = secondary.Bounds;
secondMonitor.MinimumSize = secondary.Bounds.Size;
}
else
{
secondMonitor.Visible = false;
}
There's no reason to use DirectDraw, unless you really have to. You can just as easily create a window and draw onto it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|