简体   繁体   中英

How to read and write to files in Mono

I am using Mono on Ubuntu 12.10. My application requires reading and writing from a text document and checking if specific files exist. I can't determine whether or not Mono supports this, but the following code causes the application not to run at all.

Dim objReader As New System.IO.StreamReader(Application.StartupPath + "\Data\programdata.txt")

Do While objReader.Peek() <> -1

    Form1.ListBox1.Items.Add(objReader.ReadLine())

Loop

EDIT: Resolved, I just forgot to use forward slashes.

Linux uses forward slashes as the path separator, where as I was using the backwards slash on Windows. This caused the application to crash on Mono for Linux. When changed to the forward slash, the application ran fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM