473,396 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to detect Control characters inside before I set HostName on my computer (C#)

365 100+
I am looking for some help on how to detect "Control Characters" once I receive HostName inside program, I am getting string, I am using SetComputerNameEx to set HostName, buit some times if any Control Characters present, I need to send error back. Here "str" carried string (HostName), sometimes it might contain Control characters (/\\|<>+=;,?), I need to detect and send error, how can I detect.

Expand|Select|Wrap|Line Numbers
  1.  
  2. MessageBox.Box(" Received Host Name " + str);
  3.  
  4. SetComputerNameEx(GCInfo.COMPUTER_NAME_FORMAT.ComputerNamePhysicalNetBIOS, str));
  5.  
  6. SetComputerNameEx(GCInfo.COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname, str))
  7.  
  8.  
  9.  
Dec 30 '12 #1
2 1995
Rabbit
12,516 Expert Mod 8TB
You can use a regular expression to see if it matches any control characters and if it does, show an error message.
Dec 30 '12 #2
tvnaidu
365 100+
Thanks for the hint, I got it.
Dec 30 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Greg Lindstrom | last post by:
Hello- I have a text file generated on a HP-9000 running HP-Unix with embedded control characters and would like to read it in, modify it, and write it out in PDF format. The new page character...
2
by: nowhere | last post by:
Hi, I need to preserve some ASCII control characters (CR and LF) within an XML file so I have included the data in a CDATA section. However, when parsing it using expat, I lose the CR...
8
by: Peter O'Reilly | last post by:
I have an HTML form with a textarea input box. When the user conducts a post request (e.g. clicks the submit button), an HTML preview page is presented to them with the information they have...
1
by: rcamarda | last post by:
Beyond my control: I am finding control characters (likely tab) is making its way into address fields of our operational system. This is messing me up when I load the data into our warehouse w/ BCP...
1
by: Fred Nelson | last post by:
Hi: I'm writing an error handling system for my vb.net windows application. I have an error trapping routine that is catching all unexpected errors, writing an entry in an sql database and...
3
by: Frank Niessink | last post by:
Hi list, First of all, I wish you all a happy 2006. I have a small question that googling didn't turn up an answer for. So hopefully you'll be kind enough to send me in the right direction. ...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
2
by: Bazza Formez | last post by:
I have a bound field in a DetailsView control that displays free form description type data from my SQL database table (typical data is a couple of paragraphs of written product description being...
7
by: wannymahoots | last post by:
optparse seems to be escaping control characters that I pass as arguments on the command line. Is this a bug? Am I missing something? Can this be prevented, or worked around? This behaviour...
10
by: Recursive | last post by:
I am seeking a method to detect if ASCII Control Characters are pressed. My code currently shown here is not working too well i suspect. private void Transmitted_KeyDown(object sender,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.