When saving to a text file how do i add in each line a text like: Line 1: then next line: Line 2: ?

I tried this way:
int countitems = 0;
private void SaveToListView()
listView1.BeginInvoke(new MethodInvoker(delegate
using (StreamWriter sw = new StreamWriter(@"c:\listviewfile\databaseEN.txt"))
foreach (ListViewItem item in listView1.Items)
countitems++;
sw.WriteLine("Line Number " + countitems + ": " + item.Text);
for (int i = 1; i < item.SubItems.Count; i++)
sw.WriteLine("Line Number " + (countitems + 1) + ": " + item.SubItems[i].Text);
What i get is:
Line Number 1: הכרויות
Line Number 2: 93
Line Number 2:
Line Number 2: הכרויות לגילאי 30+
Line Number 3: 1365
Line Number 3:
Line Number 3: אהבה ורומנטיקה
Line Number 4: 214
Line Number 4:
Line Number 4: א-מיניים
Line Number 5: 1493
Line Number 5:
Line Number 5: בינו לבינה
Line Number 6: 30
Line Number 6:
Line Number 6: זוגות מעורבים
Line Number 7: 257
Line Number 7:
Line Number 7: זוגיות במשבר
And what i want to get is the first line to be 1 the next line 2 then 3 4 5 6 7...
And the lines that are empty to remove them.
For example Line Number 6:
Should be empty and should be removed.

for (int i = 1; i < item.SubItems.Count; i++)
if(item.SubItems[i].Text != "")
countitems++;
sw.WriteLine("Line Number " + (countitems) + ": " + item.SubItems[i].Text);

Similar Messages

  • When saving an downloaded pdf-fil, the saved file is corrupt (empty?) and can´t be opened. Happens all the time nowadays, never before. Its a mess. Please advice.

    When saving an downloaded pdf-fil, the saved file is corrupt (empty?) and can´t be opened. Happens all the time nowadays, never before. Its a mess. Please advice.

    Hi Melbus_SE,
    Are you downloading files from your Acrobat.com cloud storage? If so, what browser are you using, and are you on Mac OS or Windows? Has something changed on your system since you were able to download/open PDF files successfully? What version of Acrobat or Reader are you using to open these files?
    Sorry to ask so many questions, but your answers will help us get to the bottom of this issue.
    I look forward to hearing back from you.
    Best,
    Sara

  • Every time i download anything, it is saved as a binary file. how do i change this setting?

    every time i download anything, it is saved as a binary file. how do i change this setting?

    Here is a simple fix I found that worked for me.
    1) Clear your download history
    2) Go to Options > Options > General Tab: Change your download location to something other than what you currently have it set at. Apply the changes.
    3) Go back into the Options and change it back to what it was or whatever you want it to be.
    You should be all set from there.

  • Using `n how can i add two empty line (two carriage return), between these two lines in the output file?

    hi friends
    using `n   how can i add two empty line (two carriage return), between these two lines in the output file?
    PS C:\> $env:COMPUTERNAME | add-content c:\file.txt
    PS C:\> $Env:USERDOMAIN  | add-content c:\file.txt
     i tested "$env:computername`n`n`n$env:userdomain" | add-content c:\file.txt   but it results in 
    myPCMyDomain
    but i wanted the contents of the output file be like this:
    MyPC
    #empty line here 
    #empty line here
    MyDomain
     i tested many other forms but didn't work.
    thanks

    I tried it, as well. The line breaks were respected in the PowerShell console, Programmer's Notepad, and Word; they weren't in Notepad.
    You are using a Unicode file.  Locale is what?
    If you just want notepad compatible line breaks then do this:
    del file.txt ; "$env:computername`r`n`r`n`r`n$env:userdomain" | add-content file.txt ;notepad file.txt
    Look in hex to see that `n is ^L or 0xA and is only one character.  CrLf is 0xD 0xA - two characters.
    My programmers editors and VS all understand a single ^L as a line break so does PowerShell.  Only DOS/Notepad and other utilitis don't understand this..
    ¯\_(ツ)_/¯

  • How would you read in each line of data and display them to message box?

    How would you read in each line of data from the _.txt file_ and display the whole data using an information-type message box?
    I know how to display each line of the .txt file data, but I do not know how to display the whole thing.
    Here is how I did to display each line of data using the message box:
    import javax.swing.JOptionPane;          // Needed for the JOptionPane class
    import java.io.*;                         // Needed for file classes
    public class problem3
         public static void main(String[] args) throws IOException
              String filename;          // Needed to read the file
              String categories;          // Needed to read the categories
              // Get the filename.
              filename = JOptionPane.showInputDialog("Enter the filname.");
              // Open the file.
              FileReader freader = new FileReader(filename);
              BufferedReader inputFile = new BufferedReader(freader);
              // Read the categories from the file.
              categories = inputFile.readLine();
              // If a category was read, display it and
              // read the remainig categories.
              while(categories != null)
                   // Display the last category read.
                   JOptionPane.showMessageDialog(categories);
                   // Read the next category.
                   categories = inputFile.readLine();
              // Close the file.
              inputFile.close();
    }I think I need to change here:
    // If a category was read, display it and
              // read the remainig categories.
              while(categories != null)
                   // Display the last category read.
                   JOptionPane.showMessageDialog(categories);
                   // Read the next category.
                   categories = inputFile.readLine();
              }but I don't know how to.
    Could you please help me?
    Thank you.

    kyorochan wrote:
    jverd wrote:
    What is not understood about your question is which part of "read a bunch of lines and display them in a textbox" do you not understand.
    First thing's first though: You do recognize that "read a bunch of lines and display them in a textbox" has a few distinct and completely independent parts, right?I'm sorry. I'm not good at English, so I do not understand what you said...
    What I was trying to say is "How to display the whole lines of .txt file in single dialog box."We know that.
    Do you understand that any problem can be broken down into smaller pieces?
    Do you understand that your problem has the following pieces?
    1. Read lines from the file.
    2. Put the lines together into one String.
    3. Put the String into the message box.
    and maybe
    4. Make sure the message box contents are split into lines exactly as the file was.
    (You didn't make it clear if that last one is a requirement.)
    Do you understand that 1-4 are completely independent problems and can be solved separately from each other?
    Do you understand that you have stated that you already know how to do 1 and 3?
    Therefore, you are NOT asking "How to display the whole lines of .txt file in single dialog box." Rather, you ARE asking either #2 or #4 or both.
    If you say once more "display all the lines of the file in one dialog box," then it is clear that we are unable to communicate with you and we cannot help you.

  • How can I add a new line item for production order?

    HI all,
    How can I add a new line item for production order through BAPI/FM? Thanks in advance.

    Hi Mil,
      Unfortunetly SAP is not in front of me.
    But if possible go to BAPI transaction , check for any production order's bapi for CHANGE purpose. Where you will be able to add your new line.
    Reward if useful!

  • How can I add a red line below all those words, which are not technically correct? And how can I do Pages to do it automatically?

    So, how can I add the red line below all those words, which are not technically correct.
    I have tried everything, but nothing works. Red line should come there automatically, but I can't find nothing from settings to do this. Can you guys help me?

    There isn't any finnish spellcheck in Pages
    Inspector palette = Asetukset
    I am trying to find out where to get a finnish dictionary that can work in Pages. I am not sure but try this
    http://www.jkwchui.com/2010/03/spellchecking-latex-in-macosx/

  • How can I add the cc line to my emails from iphoto

    I want to use the email in my iphoto program to email an invitation to a large group of people, but how do I add the cc line in my header of the email?

    You can't.  For a cc or bcc field you will have to use the regular Mail client.  However, Mail does have some photo stationary if you like the fancy iPhoto presentation of photos in the emails:
    Click to view full size
    OT

  • Firefox when saving a "complete html" file is downloading a folder and "2" copies of the html file not one. One of these has the same name but "0" kb content

    Hi. The only save options for a full html type file on Firefox is as "web page, complete" and as I say when saving with Firefox the program is saving the usual yellow folder with links and artwork files etc, but is saving 2 copies of the HTML file where on of these files is empty, won't open and gets locked to the destination it was saved to. This empty file can't be moved, and can't be deleted. When this is attempted it gives message "cannot delete (or "move" if this is the case) : Cannot read from the source file or disc."
    To overcome this I now use Internet Explorer, dut prefer not to. I have also deleted Firefox from my system and re-installed it, but this did not help. How can I stop this doubling of saved files? and how can I delete the ones that are now fixed to my desktop? can you lease help?

    You said, ''Would like to sort this one out...any clues?''
    Maybe something here will help:
    *http://en.wikipedia.org/wiki/MHTML
    *http://en.wikipedia.org/wiki/Mozilla_Archive_Format
    *http://maf.mozdev.org/
    *http://maf.mozdev.org/documentation.html

  • An issue whereby Photoshop .PSD files disappear when saved to a network file share

    It has been reported and reproduced by Support, an issue whereby Photoshop .PSD files disappear when they’re saved to a network file share.
    Upon initial investigations Support have observed the following behaviour when saving a Photoshop file.
    The document is initially saved as a new file on the file share.
    The original  .PSD file is deleted on the file share.
    The newly created file is renamed to the same name as the original file.
    An issue often arises when steps 1 and 2 complete however step 3 fails. When a file is reported by users as having disappeared, the new file created in step 1 can be renamed from  .00_ to the original *.PSD file name on the server as the *.00_ files are normally hidden by the desktop operating system. This allows people to see and open the file from both PC’s and MAC’s using AFP and SMB protocols.
    A related issue often reported by users is that they receive an error message “Could not save as” when trying to save a .PSD file. Troubleshooting the issue confirms that the user is able to save the file if they perform a “Save As” operation in Photoshop.
    From the reported problems and observations there is clearly an issue with how Photoshop performs a file save operation further exacerbated by the fact the process doesn’t fail safely.

    Sounds like you're hitting one of the known MacOS filesystem bugs - worst when working with SMB volumes.
    Apple knows about this, and we are pursuing workarounds to the OS bugs.
    Yeah, if you value your files, don't save directly to servers, especially on MacOS.

  • When saving .tif or .eps files, it usually erases the last 2, 3 or 4 letters, why? ("as copy" issue)

    hi again
    this is a question i wanted to ask the last couple of years:
    it doesnt depend on CS5 or CS4, i guess nearly all newer versions
    of photoshop erase some letters at the end of a filename, when saving as tif or eps, and the file was a photoshop .psd layer file before.
    i am working with many masks, so when i finish a psd layer file and want to save it as tiff (without layers and path) for sending out to client,
    i press "apple+alt+S" and the "save as" window checks "copy" as default, of course, i want to preserve the original filename without "..copy"
    so i uncheck "save as copy", and then there are some letters missing, i have to manually replace the letters by the original ones.
    thats very awkward and time consumptive, is there a better workaround, you could suggest?
    is this my fault, maybe wrong workflow? what could i change, in order to avoid photoshop erasing letters in filenames, when saving?
    what could i do, that "save as copy" wont appear anymore? i am always saving in another folder than the layer file folder,
    but i can only select the folder after photoshop has checked "save as copy" by itself very quick, as it thinks i want to save the tiff file
    into the .psd layer file folder...
    i am usually manually editing the filename in the finder later,
    as it has been very important for myself to stay with the original filename
    as clients use the images in indesign, so it can auto-update, if the filename is the same as before.
    thanks for any help!

    thanks for your answer!
    i am dealing with this problem within 1 or 2 years now, i guess.
    photoshop always shortens my original filename, when i press "save as"
    i am experiencing this problem on 3 macs, on different locations
    (in my homeoffice and at another office i work freelance) (very different macs and photoshop versions (from CS3 to CS5)
    like:
    original filename "vitra_woodenchair_hires_cmyk_original.psd" will be shortened to "vitra_woodenc copy.TIF"
    i have to edit the files after that manually in the finder, as i send it back to clients, and they need their original filenames.
    i also wonder why photoshop cs5 always wants to save a copy -
    i never needed a copy of a file in my life, so why "save as copy" please?
    i guess my problem is depending more or less only on the "save as copy" thing,
    as it looks like, that the letters "copy" are erasing the end of my filename.
    is there anything i can do, that photoshop wont suggest me a "save as copy" ever again?
    can i switch it off?
    your suggestion of scripts is nice, i doubt, i am able to install a script at different macs, i never ve been dealing with
    scripts before, it seems to be too complicate or it just sounds complicate to me, as i dont have specific
    file save destinations, i save at different places on different mac servers in the mentioned offices. also i save
    different kind of file types, sometimes psd, tiff, eps, jpg, png and all others...
    i try deleting .plist now and report back
    thanks meanwhile...

  • How can I add a third line of text to a title?

    I am making a music video for my highschool students to teach about recycling and I want to add a title to the bottom with the song title, the name of the ficticious band and the ficticious record label.
    I have tried to add the third line of text, but I can't seem to figure out how. the title needs to be superimposed on the actual video, so adding in a clip created in photoshop or something won't work. Think about the titles you'd see at the begginning and end of a music video, and that's pretty much what I am going for.
    Any suggestions?
    Thanks
    PS this is my first post and my first mac, so be gentle

    Bubbalouie123754 wrote:
    ....  the title needs to be superimposed on the actual video, so adding in a clip created in photoshop or something won't work. ....
    It does.
    The whole trick is to use a transparent background and using .png as file-format for your superimposed graphics:
    illustrated advice on my site
    https://sites.google.com/site/karstenschluter/imovie09tricks
    'Creating new titles'
    (advice was for vers09, does work in vers11)
    … and Welcome, Bubbalouie, to the ASC ...

  • When I type my text gets highlighted and then deleted.

    I am having a problem with typing. When I type fast my text gets highlighted and then deleted or typed over. Im not sure what is wrong. I think it is either a trackpad or keyboard. Any help be great!!

    The trackpad on the MB and MBP have a larger surface with more sensors than on previous laptops. As a result, when we type we have other fingers, thumbs etc. making contact with the trackpad and the trackpad receives input we don't intend. It happens to me quite often. So I hit Command + Z to undo and reposition the cursor. We need to train ourselves so that we keep our hands, palms, thumbs or other unnecessary body parts away from the trackpad while typing.
    cornelius

  • When syncing 2 iphones to itunes how do you avoid getting each others apps

    When you sync 2 iphones to itunes how do you avoid
    getting each others apps

    For some reason without syncing
    when I download an app the 2 phones
    get the same app. They are 2 different
    phones with 2 different apple IDs

  • When will Office 2013 Offline File Cache for IE add in work with Enhanced mode?

    The Office 2013 Document Cache Uploader IE Plugin is incompatible with IE 11 running in enhanced mode.
    I read that enhanced security mode was enabled by default in Win8 so Microsoft can collect information and advise third party plug-in developers they need to update their stuff to work with it.  Then in November, Microsoft started shipping Win8 with enhanced
    security disabled.  But Win8.1 now ships with enhanced mode enabled...   But... Microsoft's own plug-in with the latest versions don't work with it.  The solution / workaround is to disable enhanced protection mode.  (I don't see this
    as a solution for me, my last virus infection because of insecure IE cost me over $400 to fix.)  When are you going to fix your own stuff?  Or will you retire it like a bunch of other goodies ripped out of Win8.  And Server 2012.  And Exchange
    2013........Lastpass.com has their plug-in working with enhanced mode... Why can't you fix it?  Should not be that tough to fix and to include it in a Office update....

    Hope there will be a fix soon....This should not be marked as 'answer'.  You simply state the fact that it is broken as I did and to disable IE Enhanced (warning/warning) and that is not an answer or a workaround..
    Somebody please at least look at it and come up a quick and cheap, down and dirty way to add this to the trusted zones so it will work?  then you can mark as answer.  Everyone there at Microsoft sitting around waiting for someone else
    or other department to do it.  Lastpass make it work, Logmein make it work, but Microsoft resting on their laurels .......My gosh, I paid $439 for a copy of Office Pro 2013 Professional to upgrade my Office 2010 and it does not work as well as 2010 did? 
    In this respect, the product is a Lemmon.  I already moved to the cloud for Exchange like they wanted me to, by crippling connection with this to my church's Exchange 2003 server.
    It seems the master plan behind this release is to disable function with Server2003 to drive more Exchange server or Cloud hosting sales.  Please make sure the product does what it did before, before you take my money and turn off the lights on important
    feature oversites.
    Any way to hack into Office 2010 and load its cache uploader to run in enhanced zone, or put a link or dll in the trusted zone to make this feature work again?  Can someone at Microsoft at least get it on the project board or bump it up a hundred spaces
    on priority list?  Maybe offer a bonus to the programmer that fixes it.  A weekend on the hiking trail or kayak excursion, or rock-climbing pass..  Microsoft guys like that outdoors kinds of stuff and will work like crazy to get it.

Maybe you are looking for

  • ITunes could not restore the iPhone "___'s iPhone" because the backup was corrupt or not compatible

    Ok so bear with me here, it is somewhat of a long story.      I had been using an iPhone 4 for a while, with an old iTunes account that has all my stuff from over the years on it, on my computer. A week ago, I dropped by iPhone 4 in the sink and it g

  • Boot camp problem with desktop and icons

    I had installed windows 7 on my mac (2012 os x lion 10.8.2) with boot camp but when i switch on windows 7 first i see windows 7 icon and when windows xp desktop with windows 7 icons. Sounds sometimes are from windows 7 and sometimes from windows xp.

  • Payment term thread continuation with that

    Thank you all.for your  reply to previous thread of mine. So in relation to above my requirement is that Cash discount is based on payment term and differs from material to material. Suppose i maintain a cash discount of 1% for material x and the pay

  • Question about grouping.

    Hello , I have a problem in grouping my data the way i want , i have 2 tables : Orders & Modifiedorders , the Modifiedorders holds the orderid and some data about how the order is modified , sometimes the orderid in the Modifiedorders table can repea

  • Indexing table of XMLType

    Hi I have created an table in XML DB of type XMLType. Can anyone tell me how I can index this table? Oracle version is 9.2.0.3.0 Thanks