playMaker

Author Topic: Can't access text file  (Read 6708 times)

Kirdissir14

  • Playmaker Newbie
  • *
  • Posts: 12
Can't access text file
« 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:

Quote
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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support

Kirdissir14

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Can't access text file
« Reply #2 on: June 11, 2015, 07:06:53 PM »
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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Can't access text file
« Reply #3 on: June 12, 2015, 04:33:13 AM »
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

Kirdissir14

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Can't access text file
« Reply #4 on: June 12, 2015, 09:05:36 AM »
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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Can't access text file
« Reply #5 on: June 12, 2015, 09:49:34 AM »
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

Kirdissir14

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Can't access text file
« Reply #6 on: June 12, 2015, 10:02:15 AM »
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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Can't access text file
« Reply #7 on: June 15, 2015, 05:18:24 AM »
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

Kirdissir14

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Can't access text file
« Reply #8 on: July 16, 2015, 07:36:38 AM »
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?
« Last Edit: July 16, 2015, 07:39:43 AM by Kirdissir14 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Can't access text file
« Reply #9 on: July 16, 2015, 08:45:39 AM »
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 for this:

CheckIfFileExists


Bye,

 Jean