473,669 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extracting substring


string comm="CONTSCAN E:\\projects backup\\ankitcl am
backup\\Clamtes t\\testing\\hel lo.txt\r\n"
int x=comm.Length;
x=x-7;
string path;
path=comm.Subst ring(9,x);
MessageBox.Show (path);

it works fine and give path as
E:\projects backup\ankitcla m backup\Clamtest \testing\hello. txt

but when i give path
string comm="CONTSCAN E:\\projects backup\\ankitcl am
backup\\Clamtes t\\testing\r\n"
int x=comm.Length;
x=x-7;
string path;
path=comm.Subst ring(9,x); //crashes here
MessageBox.Show (path);

crashes on line : path=comm.Subst ring(9,x);

throwing exception
System.Argument .OutOfRangeExce ption:Index and length must refer to location
within the string.
Parameter name:length
at System.String.S ubstring(Int32 startIndex,Int3 2 length)
Dec 13 '05 #1
0 1158

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
14813
by: cpp_weenie | last post by:
Given a std::string of the form "default(N)" where N is an integer number of any length (e.g. the literal string might be "default(243)"), what is the quickest way to extract the characters representing the integer into another std::string? In the example above, I'd want to end up with a std:string whose value is "243". The substrings "default(" and ")" are invariant - they're always present in the string I have to work with. ...
3
1375
by: Abby Lee | last post by:
I have a string with 10 charaters 123456789A. I only want the first 6 charaters followed by the last two...getting rid of the 7th and 8th charaters. If I use document.forms.MyTextBox.value = TheString.substring()...I get the first 6 charaters. (,8,9) does not work nor does (,) and I get just as bad results with (0,1,2,3,4,5,8,9) how do I get a string with the 7th and 8th charaters missing?
3
2651
by: War Eagle | last post by:
I've been looking at .substring and .trim methods and I still have a question about extracting substrings from a textbox. Basically the textbox contains the full path to a file ... for example C:\testfile.txt or ... C:\download\temp\dlls\testfile.dll I want to be able to extract the file name from this textbox (and put it in a string) when I click a button. Can someone illustrate how to write this line of code?
6
1843
by: RSH | last post by:
Hi, I have quite a few .DAT data files that i need to extract the data out of. When i open the files in a text editor I see all of the text that I need to get at BUT there are a lot of junk (binary?) characters and white space in non logical formatting positions. Here is a small sample of what the data looks like: 0~ 0501101010512505011132451235 >   ô ô
1
7386
by: RogueClient | last post by:
Hi all, I have what I suspect is a day one rookie question yet for the life of me I can't find a good answer on the net. I need to extract a quoted substring from within a string like so: Original String: This is a 'test' Result: test Is there a simple way to do this without using complex regex expressions? It goes without saying I don't know what will be within the quotes beforehand......
1
1399
by: annaannie | last post by:
hello sir, My aim is to extract 'id' and 'ac' from given XML files,and store the results in two different files.the code i wrote can extract 'ids',and give the output in a file.But i cant extract 'ac'.I want to extract all values of ac ,for eg ac="Q708T3",ie the output file should contain only Q708T3. Kindly provide a solution. The input file( ie XML ) is as follows: <?xml version="1.0" ?> - <EBIApplicationResult...
1
1596
by: Phat G5 (G3) | last post by:
I found this little script for extracting parameters from a url but wondered what the shortest and most efficient way to do it would be, like the following or via regexp? function getParameter(paramName) { var currentUrl = window.location.search var strBegin = currentUrl.indexOf(paramName) + (paramName.length+1) var strEnd = currentUrl.indexOf("&",strBegin) if (strEnd==-1)
0
3550
by: pankajd | last post by:
hi all, i need an urgent help for writing a shell script which will extract out and print a substring which is the shortest substring from the given string where first and last character of that substring will be given by the user. for e.g. if str="abcdpqracdpqaserd" now if the user gives 'a' and 'd' as the first and last character of the substringi.e. command line arguments.this should extract out acd as the shortest string. please give...
11
4550
by: Ebenezer | last post by:
Let's suppose I have some nodes in an XML file, with an URL attribute: <node url="mypage.php?name1=value1&foo=bar&foo2=bar2&name2=value0" /> <node url="myotherpage.php?name4=value4&foo=bar3&foo2=bar5&name2=value8" /> and so on. Let's suppose I want to retrieve this @url parameter, BUT ONLY with the values, in querystring, associated with "foo" and "foo2" (thus discarding name1, name2, name4 and every other different ones).
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8587
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2029
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.