|
I have a string that looks kinda like this..
Name:Name1/Name2.Name3.Name4
If i try to save using this as the file name it calls it invalid so I need a way to parse through it and replace the illegal characters with ... say.. an underscore _
Can someone help me with this?
tia
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Assuming the variable name holding the string is 'aString',
aString = aString.Replace(@"/", "_");
will do it character by character.
I think there's also a way to replace any of a group of characters, but if so, I can't remember what it is.
|
|
|
|
|
Thanks for this info. Just the kind of thing I needed.
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
|
Martin, you beat me to recommending regex and Expresso. I'll second your suggestion
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Thanks for the info I have been trying to take all this in..
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
I need to intercept text being entered into a text box, and remove a space if it is typed. The problem with the following code is that the cursor ends up at the beginning of the string, not the end. Say the user types 'a' and then a space, i want the text box to show 'a' with the cursor after the 'a', not before the 'a'. Is there a way to specify the cursor location?
textBoxA_TextChanged (object sender, System.EventArgs.e)
{
if (textBoxA.Text.Contains(" "))
{
textBoxA.Text = textBoxA.Text.Trim();
}
}
Also, is there a way to supress the TextChanged event happening a second time, since I'm changing the text within the event handler? With a data grid, for example you can do the BeginInit/EndInit. The text box doesn't support ISupportInitialize, correct? Other things trigger off each character that is typed so I need to check character by character.
|
|
|
|
|
something like this?
bool ignoreTextChanges = false;
void textBoxA_TextChanged (object sender, System.EventArgs.e)
{
if (ignoreTextChanges)
{
return;
}
if (textBoxA.Text.Contains(" "))
{
ignoreTextChanges = true;
textBoxA.Text = textBoxA.Text.Trim();
textBoxA.SelectionStart = textBoxA.Text.Length;
ignoreTextChanges = false;
}
}
it may not be the prettiest but it should work
|
|
|
|
|
Works brilliantly! Thanks.
|
|
|
|
|
OleDbConnection mySqlConn = new OleDbConnection(SqlConnString);
OleDbCommand mySqlCom = mySqlConn.CreateCommand();
OleDbConnection mySqlConn2 = new OleDbConnection(Sql2ConnString);
OleDbCommand mySqlCom2 = mySqlConn2.CreateCommand();
mySqlCom.CommandText = "SELECT * FROM OISInt_Contact";
OleDbDataAdapter mySqlAd = new OleDbDataAdapter();
mySqlAd.SelectCommand = mySqlCom;
DataSet myDS = new DataSet();
mySqlConn.Open();
mySqlAd.Fill(myDS, "OISInt_Contact");
mySqlCom2.CommandText = "SELECT * FROM OISInt_Contact";
OleDbDataAdapter mySqlAd2 = new OleDbDataAdapter();
mySqlAd2.SelectCommand = mySqlCom2;
DataSet myDS2 = new DataSet();
mySqlConn2.Open();
mySqlAd2.Fill(myDS2, "OISInt_Contact");
mySqlConn.Close();
mySqlConn2.Close();
myDS2.Merge(myDS, true, MissingSchemaAction.AddWithKey);
foreach (DataTable dt in myDS2.Tables)
{
foreach (DataRow dr in dt.Rows)
{
foreach (DataColumn dc in dt.Columns)
{
}
}
}
mySqlAd2.SelectCommand.Connection = mySqlConn2;
mySqlAd2.InsertCommand = new OleDbCommand(String.Format("OISInt_ContactInsert", myDS.Tables));
mySqlAd2.InsertCommand.CommandType = CommandType.StoredProcedure;
mySqlAd2.Update(myDS2, "OISInt_Contact");
when I do a step into all data is in the data set and it merges but goes not commit or accept changes to the database I trying to move it to.
Learning to Code
|
|
|
|
|
My application working fine in the dev environment.But in the testing /production environment
it is not working because that environment has only
windows server 2003
IIS
.net2.0 framework
In my application I have Used some microsoft VC++ dll's also along with .net dll's.
Now Iam getting "RUNTime Error" pop-up screen message as below
" The Application has been terminated in an Unusual Way"
On googling i came to know that some dll's like msvcrt.dll of windows server 2003 has to be changed...But Iam not pretty sure about it..
In Production/test environment there is only framework installed ,but there is no visual studio installed on it.may be due that this error may occur...
So kindly post your suggestions and views to help me
I tried the following as suggested by you:
1. I have installled the redistributable package suggested by you.
after installing i restarted the PC even now also I got the same runtime pop-up error.
2. Then I checked even with the dependency walker for the dll.
I found that there is no miising dll.
3. Then I tried by installing Visual C++ express edition..even then also i got the same pop-up error.
Kindly help me.....
|
|
|
|
|
Might need to have some of those dll's your talking about to be registered with regsrv.exe. But I guess that depends on the dll's your using and your deployment method.
Just because we can; does not mean we should.
|
|
|
|
|
I have a process that causes Virtual Bytes counter to constantly increase (to the point that the program throws an OutOfMemory exception after a few hours of running), but Private Bytes are not increasing. Is there anything we can do to trigger virtual memory collection? GC.Collect is obviously not helping.
|
|
|
|
|
Managed memory doesn't get fragmented, as the garbage collector compacts the heap. If your application really leaks memory, it's unmanaged memory. Are you disposing all objects that needs disposing?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa,
I use an external C++ library (QuickFix), so I would imagine that's where unmanaged memory is used. Otherwise, everything in my code is managed C#. I thought maybe in some momemnt of lunacy I did write unmanaged code, but search for words "unsafe" or "~" or "!" produces nothing.
When you say "application really leaks memory", wouldn't it cause increase in the Private Bytes memory? I don't observe that. The Private Bytes are increasing throughout the day, but every couple of hours they drastically go down. This is really purzzling, as I am watching GC Gen 0, GC Gen 1, and GC Gen 2 counters, and they all increment so I would think that Private Bytes would be managed better. So the infrequent drastic drop in Private Bytes is puzzling. Virtual Bytes, on the other hand, never go down.
I am trying memory comparisions between WindDbg breakpoints, but that isn't going all that quickly ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Does your app do any kind of memory mapping? That would contribute to the Virtual bytes counter as well.
|
|
|
|
|
Senthil,
no, no memory mappings. Since I don't know how StreamWriter uses memory, one thing that I'd think can potentially cause problems is me writing large (GBs) log files.
It must be the unmanaged memory from the external unmanaged C++ library. I'm out of ideas as to what else can it be. The CLR profiler is showing no glaring problems with .Net-managed memory.
|
|
|
|
|
I did this!
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
string filePath = lvFiles.SelectedItems.ToString();
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\\Painel de Controle ETECH\\Projetos ETECH" + filePath;
shellExecute.Execute();
}
Am I close??
|
|
|
|
|
the event you're using will fire as you move down the list via keyboard or do single click selections. There should be a double click event. use that instead.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
|
Whenever I put a check mark on a ToolStripMenuItem it is misplaced (above the center), tried to google this bug but unsuccessful...does anyone else got this bug or is it just me? Is there any patch or will I have to custom draw the ToolStripMenuItem?
Thanx in advance
|
|
|
|
|
pacoxl wrote: does anyone else got this bug
Nope. Tried to replicate it and works fine here
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Forgot to mention: try making the ImageScalingSize of the Toolbar to 32x32
|
|
|
|
|
What did you eventually do to resolve the check mark issue? I've just encountered the same problem (VB 2008).
Thanks - AB
XAlan Burkhart
modified on Monday, September 5, 2011 2:45 PM
|
|
|
|
|
Hi All
What im trying to do is to connect three diffrent Treeview to the Sql Server in the same Database.
E.g.
Project-Database
ProjecTable1-Table inside Database
ProjectTable2
ProjectTable3
I have tried to connect but only one out of 3 tables will populate the treeview . So i am bit stuck.
If this does not make Sense please contact me craig.mutoko@iondale.com and i will explain.
I need Help Urgently.
Please Contact me ![Laugh | :laugh:](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_laugh.gif)
|
|
|
|