on 13-07-2012 11:51 AM
Hi, I was using psm v0.98 and everything was going fine, but this morning I updated it to 0.99 but now my game won't execute because there's a part in the code when I need to read a file to load some assets, the problem is that it throws an exception saying that I don't have permission to open that file. Here is the piece of code that throws the exception:
public override MemoryStream Load(string asset)
{
if (this[asset] == null)
return null;
Resource resource = this[asset];
/*if (resource.Stream != null)
return resource.Stream;*/
FileIOPermission ioPerm = new FileIOPermission(FileIOPermissionAccess.AllAccess, ASSETS_PACK_BIN_FILE);
ioPerm.Demand();
using (BinaryReader reader = new BinaryReader(File.Open (ASSETS_PACK_BIN_FILE, FileMode.Open)))
{
reader.BaseStream.Seek(resource.Offset, SeekOrigin.Begin);
byte[] bytes = reader.ReadBytes((int)resource.Size);
MemoryStream mem = new MemoryStream(bytes);
resource.Stream = mem;
return mem;
}
} Tell me if you see anything, it's odd because before updating it worked fine
I added this lines when I saw the exception but it keeps throwing it:
FileIOPermission ioPerm = new FileIOPermission(FileIOPermissionAccess.AllAccess, ASSETS_PACK_BIN_FILE);
ioPerm.Demand();
Solved! Go to Solution.
on 13-07-2012 06:36 PM
on 13-07-2012 07:38 PM
Hi:
Like you I have the same issue but I found that the folders change to read only automatically James this could be a clue?
Cheers,
on 13-07-2012 07:51 PM
no it's not the problem. I'm clue less.
on 13-07-2012 08:01 PM
Hi:
I fix my problem of access denied changing from :
FileStream stream = new FileStream(froot+file, FileMode.Open);
BinaryReader reader = new BinaryReader(stream);
to this:
//FileStream stream = new FileStream(froot+file, FileMode.Open);
BinaryReader reader = new BinaryReader(File.OpenRead(froot+file));//stream);
Hope this helps.
Cheers,
16-07-2012 07:26 AM - edited 16-07-2012 07:31 AM
The access problem was solved using your "OpenRead" aproach. but now i have another issue, the file that I want to open has in it (among other things) an xml file. Before the update it worked perfectly, now it throws me an exception at this line XElement doc = XElement.Load(stream);
it says "xmlException invalid data".
any hints on this one?
EDIT:
I think i'll create a new post for this new error. Thanks for the answers on this one ![]()
on 16-07-2012 02:12 PM
Hi:
Great =), About xml: how is the header of your xml file? it's happens in other platforms that sometimes this line is needed: <?xml version="1.0" encoding="UTF-8"?> or sometime has a bad format. I'm not 100% sure.
Cheers
on 24-07-2012 08:25 AM
on 25-07-2012 02:47 AM
Hi:
Excellent. Thanks for the advice/notice =).
Cheers,
on 29-08-2012 10:09 AM
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870