Open And Modify Text File?
Feb 12, 2011I have a C# web application (VS 2005).
I need to open an existing text file and add data to each row.
I have a C# web application (VS 2005).
I need to open an existing text file and add data to each row.
by looking at using the XmlDocument and creating elements and attributes and then inserting them into the document. Pretty soon this looked like a massive amount of work for all the elements I have to add.What are the repercussions of treating the config file as one big long text string and doing a replace at certain points to add my entries. Something like this...
private void InsertXMLElement()
{
StringBuilder webConfig = new StringBuilder();
// get the file into a stringbuilder for manipulation
using (var sr = new StreamReader("C:web.config"))
{
webConfig.Append(sr.ReadToEnd());
i have an aspx page that loads and displays a text file in a broswer window and it used to work, I made no changes to it and now testing shows additional content appended below the file.
Here is the text file:
testing...
Here is what is displayed:
[Code]....
The additional output looks like the aspx page itself, which has only a close button incase the file load fails.
Here is the apsx page:
[Code]....
Here is the code:
[code]....
I'm using a log file to document info while getting and processing info from a form
1. if not post back, open the log file, build page, send form. 2. get submit back from form, possible post back if errors, possible writes to log file, if no errors definitely writes to log file, and send confirm page. 3. postback from confirm page can either be going back to form or finalizing, and send acknowledge page, then done.
so I need to keep the logfile object between direct postbacks to the form, or posting back to orignal form page after gettting a postback from a confirm page.
this type of file setup works fine, it creates a single log file per day:
[Code]....
then successive writes are like this:
[Code]....
when the form submit comes back from the original send/submit, lf from above is 'nothing'
saw the post about 9 ways to maintain state, not sure at all which would be most appropriate to keep the lf object accessible between possible postbacks and submits to the form.
This is what I have right now for a file residing on the same server and it works.
Dim FILENAME as String = Server.MapPath("Output.txt")
Dim objStreamWriter as StreamWriter
objStreamWriter = File.CreateText(FILENAME)
dr = myCommand.ExecuteReader()
While dr.Read()
objStreamWriter.WriteLine("{0}|{1}|{2:yyyy-MM-dd}|{3:yyyy-MM-dd}", dr(0), dr(1), dr(2), dr(3))
End While
objStreamWriter.Close()
I was planning on FTPing the file to another server once done but is there a way to do it on a remote server? i.e create a text file on a remote server and write to it? Did not find any instances of that usage. How to use ServerXMLHTTP to replace Server.MapPath in this instance?
i trying to write some text to a file in browser system......for this i'm using stream writer as like this
StreamWriter sw = new StreamWriter("c:/Billing report.doc");
but wat i need is browser should open a dialog box and ask open or save.
i have a fileupload control which i use to upload file to the server. after the upload is successful i enable a hyperlink with the name of the uploaded file.
i want the user to be able to view this file in the browser after the file has been uploaded.
i did try assigning the navigateurl for the hyperlink = HttpContext.Current.Request.MapPath(".") + "\folder1\" + fileName;
which dint work. all uploaded files are being stored in a folder inside my solution directory on the server.
Is there a pre-existing library to extract plain text form Open XML file formats (e.g. docx, pptx, and xlsx) files?
I require this to populate a lucene.net index.
I've found this example which extracts text from docx and it seems to work okay. But before building my own solution based on this I was wondering if there's something already available for the other file formats?
I am thinking about opening a PDF file with some editable fileds in the browser , by which i can modify the PDF file / fill information etc and then save that PDF FORM
View 7 RepliesHow can I modify the attached code to open the linked web page in a new window?
[Code]....
I am stumped on this one. I want to modify the text in a Hyperlinkfield of Gridview after the data is bound to it. I found similar code to this on msdn and I can't get it to work.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].Text = e.Row.Cells[2].Text + "random text";
}
I also tried similar code in the Page_PreRender event with no luck. I have also tried calling DataBind() before this one line of code with no help. I always just get "random text" in the cell without the data from the DB.
I have been trying to find out how I can allow a user to modify/update a page/pages on a web site. I understand there has to be site security with authentication and authorisation but what is there as a user interface for them easily to update a page?
View 4 RepliesI m using FileUpload Control , when i click the fileupload text box , Choose file window have to open.
View 6 RepliesWhen i try to open a csv file from my asp.net 3.5 app by clicking on the link provided, a file download dialog box appears.When i click on the open button from there , i get this eror
C:Documents and settingsUserNameLocal SettingsTemporary Internet FilesContent.IE5X9TXTM06myfilename.csv could not be found .Check the spelling of the file name and verify that the file locationis correct?
Wjy am i getting this error? I am trying to open a file and it complains about file not found in the Temporary Internet Folder.I tried deleting the temp intrnet files.Dint work.I have IE 7 on xp professional sp3. Also i am streaming the file from the application. This happens only to some files and the rest of the files , i can open .
I would like to find a way to read a txt file (in my case delimited by €). I need to change the order of the columns and also add and remove some columns. My output file should be a txt file delmited by ;.
I tried Jet.OLEDB to read the file and put it into a datatable and then used a stringBuilder and streamwriter to get an output file in .txt format. However. This does not me since IŽ, reading the txt file from start to end and my output will be the same. It does not seem like I can have a custom sql statement when reading the file. The only query that works is
Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from 1.txt", TextConn)
How can I possible modify a txt file?
This is my code for now:
[Code]....
I have a radiobuttonlist control in an AJAX tabpanel, which I would like not to postback whenever the selected item is changed. But I do want to modify the text in a textbox, that is within a separate updatepanel, to be the text of the new selected item.
View 2 Replies perhaps i have found a bug in Visual Studio 2008 Team Edition.Every thing was going well.
I started to build my project, but for certain reasons i went to Built Tab and while the project wes in build process i clicked Cancel Button.Alas!! after that my class file has gone to non-editable mode.It is giving this error:
"cannot currently modify this text in the editor.It is read only ".I closed and again opened Project but no improvement.I went to Tool->Import Export Setting->reset all settings but no benefit.
I am doing some research on themes in asp.net. (Just Learning) is this a practical use of my time? Should I just use css files and if someone wants to modify anything let them use the css to do it? Are themes a waste of my time? I really want to create my app but give the end user the ability to customize the look and feel without jumping through hoops. Can someone push me in the right direction with pros, cons etc
View 3 RepliesI have created a pdf file using aspose and need to open it without saving the pdf.Is it possible.
View 1 RepliesI am trying to open a file share link from the window.open ... but its adding the http://localhost/vdir/ before the path can any one say what is the problem?
View 1 RepliesWhen the user clicks on "OPEN" button, It should open up that(.txt) file which is on the file server in ReadWrite Mode (like in notepad) without any Access Issues.
Or simply has to be openend as temporary READONLY .Txt File. So that the user can close after viewing it.
I have been trying to overcome the well know issue of importing a csv file, nut ignoring the comma's within the quotes. Not every field has quotes, and not every record has comma's withing the quotes. After spending ages looking at various samples and arguments, Im still baffled. I have below a qiuck sample of a file ( we can not change the file at all ) , what i want to get out of it, and the the procedure i am currently working with. Can anyone show and explain how to modify my sub to get the desired results
"Smith, John", "125 My Street ","MY1 25Q", 135.00
"Jones,Fred","Flat 1, 139 Hight Street", "UB8 8UU",798.00
(0) Smith,John
(1) 125 My Street
(2) MY1 25Q
(3) 135.00
(0) Jones,Fred
(1) Flat 1, 139 Hight Street
(2) UB8 8UU
(3) 798.00
[Code]....
I want to add the new tables to dbml file dynamically from another database
View 2 RepliesI have some pages that reference javascript files.
The application exists locally in a Virtual Directory, i.e. http://localhost/MyVirtualDirectory/MyPage.aspx
so locally I reference the files as follows:
<script src="/MyVirtualDirectory/Scripts/MyScript.js" type="text/javascript"></script>
The production setup is different though. The application exists as its own web site in production, so I don't need to include the reference to the virtual directory. The problem with this is that I need to modify every file that contains a javascript reference so it looks like the following:
<script src="../Scripts/MyScript.js" type="text/javascript"></script>
I've tried referencing the files this way in my local setup but it doesn't work.
I have been asked to modify an ASP.NET 3.5 web application. The solution file does not appear to be present on the web server, but there is a DLL. Is it possible to modify the solution by "reverse engineering" the DLL?
View 2 Replies