Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Kirdissir14 on June 11, 2015, 01:04:46 PM
-
When I try to access a .txt file with "Load From File" it says Access denied. I'm running Unity as admin and deactivated my antivirus. Here is the full error:
UnauthorizedAccessException: Access to the path 'E:\Unity\VPE_PLM01\Assets' is denied.
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/FileStream.cs:259)
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
System.IO.File.OpenRead (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:363)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/StreamReader.cs:167)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding)
(wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string,System.Text.Encoding)
System.IO.File.ReadAllText (System.String path, System.Text.Encoding encoding) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:587)
System.IO.File.ReadAllText (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:582)
HutongGames.PlayMaker.Actions.LoadFromFile.Load () (at Assets/PlayMaker Custom Actions/Files/LoadFromFile.cs:55)
HutongGames.PlayMaker.Actions.LoadFromFile.OnEnter () (at Assets/PlayMaker Custom Actions/Files/LoadFromFile.cs:36)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex)
HutongGames.PlayMaker.FsmState.OnEnter ()
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState)
HutongGames.PlayMaker.Fsm.UpdateStateChanges ()
HutongGames.PlayMaker.Fsm.Start ()
PlayMakerFSM.Start ()
Can anyone help me out please?
-
Hi,
you need to run Unity as administrator:
http://answers.unity3d.com/questions/192841/access-to-path-is-denied-at-project-start.html
else try this:
http://essayprograming.blogspot.ru/2014/06/unauthorizedaccessexception-access-to.html
Bye,
Jean
-
Thank you for the response Jean. As I said, I already tried admin. Now I followed the instructions from the second link and it doesn't help either. I even tried several different folder locations on different HDD.
Any other idea? Or is there a whole other way getting textfiles into Unity with playmaker?
Kind regards
-
Hi,
yeah, you could try to copy paste the file to a different location. the e drive is generally a cd rom or dvd drive in common pc setup, so this could play a role. try to move it somewhere else.
if you can't do that because of the nature of your environment and how it's going to run on the client's computer, then I am not sure.
Have you tried to run it when published? is it happening only in editor would be the question to answer at this point.
Bye,
Jean
-
Hi Jean,
I have already tried it at C: and D: but still no progress. I even tested the published build version (running as administrator). I have no idea what else I could do.
Kind regards
-
HI,
most likely anti virus. Can you disconnect from the internet, turn off your anti virus completly and test?
WARNING: be careful, your computer will be at risk if you do this. so this is the last resort. before you shoudl triple check everything again, starting with your anti virus and possible white list Unity and your app so that the anti virus let it do what ever it wants.
Bye,
Jean
-
Deactivating antivirus, internet connection and firewall didn't help either.
Nevertheless I figured out a small solution:
I am only allowed to use the following folder "E:\Unity\VPE_PLM01". That's the folder where my build.exe is located. It even works with antivirus and internet turned on. Is that the expected behaviour? I find it rather strange that I can only use this path.
Kind regards
-
Hi,
I am not too sure myself. I'll run some tests this week. please bump towards end of week if I haven't responded. Thanks :)
Bye,
Jean
-
Bumping this as wanted (even though I'm late)
Actually I am running into another error. The "Load From File" action won't let me execute the alternate actions if it fails to load the file. This can in my case happen if the user makes a wrong string input which is not a valid .txt filename. Is there any way to check if the file exists?
-
Hi,
I would try this https://www.assetstore.unity3d.com/en/#!/content/4598
The have a windows demo, if you can access your files, then that will be the way to do it.
As to check if a file exists: I made an action on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) for this:
CheckIfFileExists (https://github.com/jeanfabre/PlayMakerCustomActions_U3/blob/master/Assets/PlayMaker%20Custom%20Actions/Files/CheckIfFileExists.cs)
Bye,
Jean