generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: IO Exception was unhandled?

Previous Thread :: Next Thread 
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
16 Jan 2012 12:59 PM
I keep getting that error on this code (C#)

using System;
using System.IO;

namespace fileWrite
{
public class writeClass
{
public static void create(string fileBody, string filePath)
{
string path = Path.Combine(filePath, "File.lua");
var sw = new StreamWriter(path);
File.WriteAllText(path, fileBody);
}
}
}

Can anyone help :x? It's saying that "it is being used by another process."
Report Abuse
pokelover980 is not online. pokelover980
Joined: 12 Jun 2009
Total Posts: 4141
16 Jan 2012 01:12 PM
It means the file is being used by another process. The error isn't something that's vague, close any other process that has "File.lua" open. And handle exceptions in code so your program doesn't terminate (hint: try-catch blocks).
Report Abuse
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
16 Jan 2012 01:32 PM
Well, how is it being used by something else?
Report Abuse
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
16 Jan 2012 02:19 PM
bump
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
16 Jan 2012 02:20 PM
try-catch blocks.


----------
    ~ pwnedu46, the unicorn ~
Report Abuse
pokelover980 is not online. pokelover980
Joined: 12 Jun 2009
Total Posts: 4141
16 Jan 2012 03:03 PM
"Well, how is it being used by something else?"

Exactly how the error says it is: You have it open in another process.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
16 Jan 2012 03:05 PM
Are you editing it with notepad?
Did you forget to close an old version of that program?

~Atheist, dutch, canadian, programmer, "markuper"
Report Abuse
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
16 Jan 2012 03:06 PM
Here is the error I got with catch

System.IO.IOException: The process cannot access the file 'C:\Users\Laptop1\AppData\Local\Roblox\plugins\Mew903_Created_Plugin\Plugin_Script.lua' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding)
at System.IO.File.WriteAllText(String path, String contents)
at FileWrite.writeClass.create(String fileBody, String filePath, TextBox textBox3) in C:\Users\Laptop1\AppData\Local\Temporary Projects\Roblox Plugin Maker\FileWrite.cs:line 15


:c
Report Abuse
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
16 Jan 2012 03:07 PM
And booing, I'm using Visual C# 2010
Report Abuse
LocalChum is not online. LocalChum
Joined: 04 Mar 2011
Total Posts: 6906
16 Jan 2012 04:19 PM
The StreamWriter opens it so that you can't use WriteAllText. Get rid of the StreamWriter to make it work.
Report Abuse
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
16 Jan 2012 05:35 PM
^

Read my other thread
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image