|
Do you know why I do not get the list of printers on a particular Remote machine (win server 2003 SP2) using the following code?
No error is returned.
PrintServer myPrintServer = new PrintServer(@"\\" + txtServerName.Text.Trim());
// List the print server's queues
PrintQueueCollection myPrintQueues = myPrintServer.GetPrintQueues();
String printQueueNames = "My Print Queues:\n\n";
foreach (PrintQueue pq in myPrintQueues)
{
printQueueNames += "\t" + pq.Name + "\n";
}
|
|
|
|
|
How do i append the character \ to a string
rtf = rtf + @"\"; this is not working now is this
rtf = rtf + "\\"; neither this
rtf = rtf + "\";
Thank you.
|
|
|
|
|
Both of the first two work fine for me.
3rd one won't work because the \ sign is escaping the second " so you never actually close the quotes.
Simon
|
|
|
|
|
Thank you
for me the first two lines are adding two // but i want only 1 and the last one is an escape char.
|
|
|
|
|
Are the two \'s appearing in your output, or only in the debugger? The latter will of necessity show slashes used as escape characters when you look at a string. If it's the former, you need to provide a small program that reproduces this so we can see what you';re doing wrong.
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
|
|
|
|
|
Its because you are viewing it in the debugger I suspect. If you just hover the mouse over it it shows \\, but if you look at it using the text visualiser it will be correct. Its caught me out before...
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thank you all for your assistance
Yes im viewing in the debugger, my problem is i want to search for a string and replace it with another but on the one im searching i want to append the "\" to it.
like
string str = @"\\";
string rtf1 = rtf.Replace("alt=\"\" src=\"/Web%20Cleint/Home%20Page/Images/Stop.png\"", rep);
rtf = rtf.Replace(MatchList[i].ToString() + str.Substring(1,1), rep);
on rtf1 there is a "\" after the pgn. but MatchList[i].ToString() doesnt have the "\" and i cant include it in my search(regx) as well.
|
|
|
|
|
No you can't
"abc\" is impossible...............
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
\ is an escape character both in C# and RTF, so you'll have to escape it twice.
rtf = rtf + @"\\";
or
rtf = rtf + "\\\\";
|
|
|
|
|
Thank you all for your assistance
Yes im viewing in the debugger, my problem is i want to search for a string and replace it with another but on the one im searching i want to append the "\" to it.
like
string str = @"\\";
string rtf1 = rtf.Replace("alt=\"\" src=\"/Web%20Cleint/Home%20Page/Images/Stop.png\"", rep);
rtf = rtf.Replace(MatchList[i].ToString() + str.Substring(1,1), rep);
on rtf1 there is a "\" after the pgn. but MatchList[i].ToString() doesnt have the "\" and i cant include it in my search(regx) as well.
|
|
|
|
|
rtf = "Testing Image Embading \r\n<src> \r\nEmage Embabeded here\r\n"
Regex exp = new Regex(@"img (alt=\.)?([^\.]+)\.png", RegexOptions.IgnoreCase);
string InputText = rtf;
MatchCollection MatchList = exp.Matches(InputText);
Match FirstMatch = MatchList[0];
for (int i = 0; i < MatchList.Count; i++)
{
string str = @"\";
string rtf1 = rtf.Replace("alt=\"\" src=\"/Web%20Cleint/Home%20Page/Images/Stop.png\"", rep);
string strToReplace; //= MatchList[i].ToString(); //;+ str;
//strToReplace = strToReplace.Substring(0, strToReplace.Length);
strToReplace = string.Format(@"{0}\", MatchList[i].ToString());
rtf = rtf.Replace(strToReplace, rep);
i hard corded rtf1 and it worked fine so what i want is for strToReplace to be equal to this string Web%20Cleint/Home%20Page/Images/Stop.png\"
and im trying to achieve that by using this string string strToReplace; //= MatchList[i].ToString() + str;
it appends 2 \\ and doesnt match the other string
I hope this will help.
|
|
|
|
|
This is my code snippet
foreach (KeyValuePair<string,> keyValue in queryList)
{
string strQuery = keyValue.Value;
Progress.lblMessage.Invoke((MethodInvoker)delegate()
{
Progress.lblMessage.Text = "Creating table " + keyValue.Key;
Progress.Text = m_fmProgress.lblMessage.Text;
});
new SqlCommand(strQuery, sqlConn, sqlTransaction).ExecuteNonQuery();
Progress.lblMessage.Invoke((MethodInvoker)delegate()
{
Thread.Sleep(100);
Progress.pbCurrentProgress.Value =
Convert.ToInt32(iProgress * (100.0 / queryList.Count));
Thread.Sleep(50);
});
iProgress++;
}
Is this method is correct to show progress
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Background: I built a really cool chat that just uses ajax and asp.net pages. Its even event based. I had to build it because nothing else out there does what I want.
Problem: I have to store the chat messages and some other things as global variables in the application variable. Like List<chatmessage> msgList.
But I get invalid cast exceptions when I try to initialize a local variable of the same type. Its because its not thread safe. So, from different threads List<ChatMessage> isn't the same type.
my only other solution is to create a separate list for each property of ChatMessage. like List<string> msgList_msg; List<string> msgList_is_blocked, List<string> msgList_date, List<string> msgList_userId.
I don't want to do that but I don't feel like I have a choice.
Any Ideas or Suggestions?
modified on Tuesday, September 30, 2008 9:09 AM
|
|
|
|
|
InvalidForumException was thrown by your question. Please make sure you post your question in correct forum. Your post has been terminated.
|
|
|
|
|
Good one
The need to optimize rises from a bad design
|
|
|
|
|
Thanks
|
|
|
|
|
this is the true new kind of exception that i can find only in this forum, Chris should have this as a shortcut
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
hi
i use these code for restore
this.openFileDialog1.ShowDialog();
if ((this.openFileDialog1.FileName != "") && (this.openFileDialog1.FileName!="openFileDialog1"))
{
try
{
filename = openFileDialog1.FileName;
SqlConnection SqlCon = new SqlConnection();
SqlCon.ConnectionString = global::project.Properties.Settings.Default.dabirkhanehConnectionString;
SqlCommand SqlCom = new SqlCommand();
SqlCom.Connection = SqlCon;
SqlCon.Open();
SqlCom.CommandText ="ALTER DATABASE dabirkhaneh SET SINGLE_USER WITH ROLLBACK IMMEDIATE" +" USE master; RESTORE DATABASE dabirkhaneh FROM DISK =N'"+filename+"'";
SqlCom.Connection = SqlCon;
SqlCom.ExecuteNonQuery();
SqlCon.Close();
SqlCon.Open();
SqlCom.CommandText ="ALTER DATABASE dabirkhaneh SET MULTI_USER ";
SqlCom.Connection = SqlCon;
SqlCom.ExecuteNonQuery();
SqlCon.Close();
MessageBox.Show("بازیابی با موفقیت انجام شد");
}
catch
{
MessageBox.Show("بازیابی با موفقیت انجام نشد");
}
}
but i have error;
The tail of the log for the database "vezaratekar" has not been backed up. Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose. Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.
RESTORE DATABASE is terminating abnormally.
Changed database context to 'master'.
please help
thanks
|
|
|
|
|
This would be SQL and Database discussions[^] question.
However, the error is very clear. Have you tried tail-log backup before restore or forced restore as the error describes?
The need to optimize rises from a bad design
|
|
|
|
|
Sometimes my projects require external files, for example DLL-files or GIF-images. I would like to include those files inside the exe-file so I only have one file to distribute to the users. It would be acceptable to put the bytes from the files into arrays and then somehow make those arrays look like files to the software. How do I do that?
|
|
|
|
|
If you want to merge things together, take a look at ilmerge[^].
|
|
|
|
|
Apart from IlMerge that Pete suggested, you can use .NETZ[^]
|
|
|
|
|
Thanks for your suggestions. However, there are some cases where I'd really like to include the file-data inside my source code. For example, in a lot of my project I'm re-using a custom-made MessageBox with an hour glass and it bothers me that I also need to include the gif-file with the hour glass icon every time I need to use this piece of code. I think it would be much more convenient to have everything inside the same class and file. How can I do that?
|
|
|
|
|
If you add the gif file to the resources of your custom made messagebox then you will not need to include it in every project.
|
|
|
|
|
How do I do that? My MessageBox is just a plain .cs file, I did not use the designer in Visual Studio to create it.
|
|
|
|