.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Search string (in txt file) --> Get the string between quotes which comes after it --> Add item in l

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application

Hello :)

I've mentioned my complete objective in the title.

I already know how to find a string, and add a item in listbox.
But so far I kept failing at retreiving the string between the quotes

My txt file looks like this:

List of delicious fruits ( Index 1 "Apple") ( Index 2 "Cherry") ( Index 3 "Banana") (...) (...)

The listbox has to view this :

Apple Cherry Banana

This is how far I got.

public void fruitFinderBlock()
 StreamReader reader = new StreamReader(@"C:\TEST.txt");
 string content = reader.ReadToEnd();
 while (content != null) // while not at end of file
 string Find = "Index";
 if (content == Find)
 string fruitname;

 // TODO assign fruitname to the string between the quotes 

View Complete Post

More Related Resource Links

Search for a string in my datasource dynamically


I am displaying an Rssfeed on my page by using XmlDataSource and Datalist controls.

I want the user to be able to limit the information that is returned to my datalist.  To do this I have a textbox on the form that allows the user to enter their search criteria.

I need to be able to dynamically create a query string utilizing the information that the user entered in the textbox.  I am also using a drop down list and allowing the user to select whether they want to search in the title, description, or all parts of the xml file.

I am having trouble figuring out how to reference the data contained in my textbox in my query string.  Where the query string says 'asp', I want to replace 'asp' with the content from my sSearch variable.  Can anyone tell me how to reference my variable in the query string???

string sSearch = txtSearch.Text;
        string SQuery = "";

        if (DropDownList2.SelectedIndex == 0)
            SQuery = "[contains(title), 'asp')]";

Writing connection string in web.config file by code or dynamically

I want to write connection string in web.config file of my application by code. If anyone know the way or code just help me..NET,C#,SQL SERVER

Weird Issue with the MOSS Search : FileExtension metadata object type instead of string

Hello, We 've got a strange issue with the search and especially with the FileExtension metadata. when we make a query on the search engine, we receive for the FileExtension metadata an unexcpected result. here is a printscreen showing the issue. http://cid-53eee937847a625e.photos.live.com/self.aspx/Public/Untitled.jpg as you can see the Type of the FileExtension is object and it should be string and I checked the type of the object and it's System.String[] the element at the index 0 contains the value! what's wrong ? thx in advance

writing xml data to a string instead of a file

Hi   I have a code that generate xml file from a database table and write the data in a xml file that is created by the program itself  // create xml file and xml writer XmlTextWriter xmlwrtr = new XmlTextWriter("c:\\SitemapTEST2.xml", null); I would like to write the xml data as a string and pass it to a datasource connection , how is this possible? something like this  this.ExplorerBarDataSource.Data = @"<?xml version='1.0' encoding='UTF-8'?> <countries> <country name='United States'> <state name='Alabama'> <city name='Montgomery' pubulation='22,000'/> <city name='Birmingham'/> <city name='Tuscaloosa'/> <city name='Huntsville'/> </state> </country> </countries>";     thanks    

write Custom MemberShip provdider only to read the connection string from other file

hi,    In asp.net mvc project I am using MYSQlMemberShipProvider. Now I want that instead of reading the connection string from web.config file, it will read the connection string from external file every time. So that I am implementing the cutsom mebership provider class, this class inherits the MemberShipProvider class.    But the problem is that if I inherits the MemberShipProvider class then I have to impelment all of its method in my cutsom membership provider class, But I want to use all other inbuilt methods of MemeberShip. What can i do.I only want to add the code like below: public class CustomSqlMembershipProvider :MembershipProvider    {        public override void Initialize(string name, NameValueCollection configs)        {            base.Initialize(name, configs);                Connectionstring objProducts = // redaing the connection string.   }}But on compiltaion it is giving me the error does not implement inherit abstract member. Please Suggest me any idea.        Thanks In AdanaceAayushi

For MYSQLMemberShipProvider read the connection string from external file at run time

Hi, In my asp.net mvc application, I have used "MYSQLMemberShipProvider" .I want to read connection string from external file at run time.I am using MYSQL connectore 6.3.4How can I do thatThanksAayushi

SPList.WorkflowManager.StartWorkflow(SPItem item, SPWorkflowAssociation association, string initiati

I want to know initiationData Data format in this method  please help me .I want send some integer to workflow but I dont know initiation data format.??

Encrypting config file's connection string and keys


 Is aspnet_regiis.exe secure? If i encrypt using aspnet_regiis.exe, will it automatically decrypt the string and wont give any error? Need an insight into this stuff....any suggestions? Is Rsa the best option or wat? Wat's the best way to encrypt/decrypt programmatically?

SP Search from Windows 7 Start Menu: No reset of search string?


Try to enhance the search experience for our Windows 7 users. Have enabled the group policy setting User\Policy\Windows Components\Windows Explorer\Pin Libraries or Search connectors to the "search again links"and the Start menu and populated it with the value https://sharepoint.company.ch/SearchCenter/Seiten/results.aspx?k={searchTerms}&s=Alle%20Websites.

It works perfect when performed a Sharepoint search the first time. However, when searching a second time, the search string that should be provided by {SearchTerms} is not transferd correctly, and the search result (and the displayed search terms) are identical to the first search.

Any advice? Thank you in advance for any help!


Importing text file datetime string into SQL datetime column



Using SSIS 2008 R2 to import text files.  Two of the fields contained are datetime values in the format "2010-09-24 18:58:29.220".  Ultimately both the date and time need to be extracted with precision to the second, at the very least.  When I import the text file, however, the time value seems to get truncated before the date value's being imported, for an imported result of "2010-09-24 00:00:00.000".

Is my problem with the Flat File Connection Manager?  Regardless of which DataType choice I use for the properties of my datetime values--I've tried every form of date datatype--the imported column values contain the correct date but the wrong time value.

Is there an easy way to import a text file datetime value straight into a datetime column?  Is it possible, or am I trying to shortcut what should be a proper process?


Importing text file datetime string into SQL datetime column



I'm importing a text file into SQL Server 2008 R2 using SSIS 2008 R2.  Included in the text file is a datetime column with values like "2010-09-24 18:58:29.220".  However, when I import the file, the stored value has the time portion replaced with what I assume is the default, such as "2010-09-24 00:00:00.000".

Is there an easy way to import a datetime value from a text file into a datetime column in my table?  I've tried every form of date datatype in the Flat File Connection Manager, but I still keep getting the correct date portion with the incorrect time portion.

Am I trying to do something that wasn't intended?  I see Todd McDermid's page (http://toddmcdermid.blogspot.com/2008/11/converting-strings-to-dates-in-derived.html) and am starting to wonder if perhaps I'm trying to shortcut something that I shouldn't.


To convert an string to a XML File?



     I have converted an XML file content to a string.. Now i want to write the same string to a new XML file.. Can someone help me out?


string strXML = "<CountriesList><Countries> <CountryName>Austria</CountryName></Countriees></ContriesList>";

   I want to convert the above string into a New XML File..


add string in existing resource file


hi there
i need to add a string in a existing resource file
i am trying this but does not work
do you know the problem?

Private Function AddString(ByVal file As String, ByVal result As String)
        Dim language As Google.API.Language = Google.API.Language.English

        Dim resxFilePath As String = file '"c:\files"  

        Using rr As New ResXResourceReader(resxFilePath)
            Dim outputFilePath As String = resxFilePath.Replace(".vb", "") & ".resx"

            Using rw As New ResXResourceWriter(outputFilePath)

                rw.AddResource(result, Replace(result, Chr(34), ""))


            End Using
        End Using

    End Function

Load XML data (string format - not file) into a gridview




 I need some help help loading some XML tagged data I received as a reply from a Web Service (String format), into individual fields on the web form.


After spending some time,  I was able to load an XML file into a gridview using this code...

<?xml version="1.0" encoding="ISO-8859-1"?>
        <title>Empire Burlesque</title>
        <artist>Bob Dylan</artist>
        <title>Hide your heart</title>
        <artist>Bonnie Tyler</artist>
        <company>CBS Records</company>

how to pass XML file path as input string to a Stored Procedure


Hello All,

I need to pass the file path (or hardcode the XML file path ) of an XML file to a stored procedure. This SP will then read the values from the XML file and based on these values the Insertion / updation will be done thereafter.

I am not able to pass the XML file path to this stored procedure.  Right now I an doing as givn below :

DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='
  <add key="approvalMode" value="On" />
EXEC sp_xml_preparedocument @idoc OUTPUT,'c:\Inetpub\wwwroot\HealthandSafety\Aspx\ApprovalMode.xml'

FROM OPENXML (@idoc,'/configuration/appSettings/add',0)
      WITH ([key]  varchar(10),
            value varchar(20))
EXEC sp_xml_removedocument @idoc

Here any change in the xml file needs to be changed in the SP too. This will lead to double work as later on this SP will be made as an SQL job.

Is there a way I can pass or hardcode the XML file path in the SP rather than duplicating the XML file contents again

Please advice!!

Workflow create item returning integer... Should be a string.




Im passsing information to a new item in a different list using the create item workflow.


It seems to work from apart from one, critical field. The create item should (i hope) pass a valie from a field  'FIELD' in List A to 'FIELD' in ListB.   in list a the field is a lookup from a reference list.

The create new List item workflow ____ it but only returns the type as an integer (an its the oonly option) .

Can you explain where im going wrong?


Writing multiline string to file using Javascript


hi all,

i have a string which is the mimecontent of the mail.

this is want to save it in a eml format.

we can do so by just writing this string in a file with .eml extension.

i want to do this using javascript as i need to wrrite this file on the local machine.

i m facing problem with the new lines and the "" in the string

can any body help me with it.

for reference i m attaching the mime content of the mail.

Received: from EXCH2010.domain.com ([fe80::f5fb:37bb:c9cb:28f6]) by
 EXCH2010.domain.com ([fe80::f5fb:37bb:c9cb:28f6%11]) with mapi; Tue, 30 Nov 2010
 11:42:42 +0530
From: Administrator <Administrator@domain.com>
To: Administrator <Administrator@domain.com>
Subject: Test Mail
Thread-Topic: Test Mail
Thread-Index: AcuQVYqRVfN+1rpjQw2fGc09+XQgrQ==
Date: Tue, 30 Nov 2010 06:12:19 +0000
Message-ID: <2D99BF2A46A0DE419BFB787BECB0122B15116A11@EXCH2010.domain.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 04
X-MS-Exchange-Organization-AuthSource: EXCH2010.domain.com
X-MS-Has-Attach: yes
X-MS-Exchange-Organization-SCL: -1
Content-Type: multipart/mixed;

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend