Jump to content
Sign in to follow this  
aismen

[C#]Problema File.OpenRead

Recommended Posts

Salut,

 

Folosesc 

File.OpenRead

ca sa preiau un fisier si sa il fac FileStream, ca sa ii pot calcula MD5. Problema este ca primesc eroare la fisiere de genul:

 

Could not find file 'C:\Windows\System32\spoolsv.exe'.
Could not find file 'C:\Windows\System32\spoolsv.exe'.
Could not find file 'C:\Windows\system32\taskhost.exe'. 
Could not find file 'C:\Windows\system32\taskhost.exe'. 
Could not find file 'C:\Windows\System32\VBoxTray.exe'. 
Could not find file 'C:\Windows\System32\VBoxTray.exe'.
Could not find file 'C:\Windows\system32\csrss.exe'.
Could not find file 'C:\Windows\system32\csrss.exe'. 
Could not find file 'C:\Windows\system32\winlogon.exe'. 
Could not find file 'C:\Windows\system32\winlogon.exe'. 
Could not find file 'C:\Windows\system32\AUDIODG.EXE'. 
Could not find file 'C:\Windows\system32\AUDIODG.EXE'. 
Could not find file 'C:\Windows\system32\lsm.exe'. 

Aplicatia mea cere drepturi de administrator si dialogul UAC apare, dar vad ca tot imi da eroare pentru fisiere din system32... Imi puteti spune ce as putea face sa trec de problema asta? Am cautat pe stackoverflow si toti zic ca nu am drepturi suficiente, dar eu cer administrator...

Share this post


Link to post
Share on other sites

Ii dai run as admin la visual studio la pornire?

Sau cacaturile astea?

https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

OR

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

OR

<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

 

Si mai era chestia asta de adaugai un 21 la shortcut si facea treaba:

https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator

Bafta!

Edited by gigiRoman

Share this post


Link to post
Share on other sites
14 hours ago, gigiRoman said:

Ii dai run as admin la visual studio la pornire?

Sau cacaturile astea?

https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

OR

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

OR

<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

 

Si mai era chestia asta de adaugai un 21 la shortcut si facea treaba:

https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator

Bafta!

 

Da, VS ruleaza as admin, si in manifest am asta

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Care cica e cu drepturi maxime...

 

 

Edit: Aparent e o problema daca aplicatia e pe 32bit sau pe 64 cu File.OpenRead. Am debifat "Prefer 32bit" din build si acum nu mai am problema.

Edited by aismen

Share this post


Link to post
Share on other sites
10 minutes ago, Erase said:

Formatul este irelevant. Pentru a citi un fisier nu ai nevoie de acces de administrator.

 

Am debifat "Prefer 32bit" la Build si acum merge.

Share this post


Link to post
Share on other sites

NetFramework iti returneaza exceptia FileNotFound atunci cand accesezi un path invalid si UnauthorizedAccess cand nu ai drepturi suficiente pentru actiunea respectiva.
http://blogs.microsoft.co.il/sasha/2012/04/04/what-anycpu-really-means-as-of-net-45-and-visual-studio-11/

 

Referitor la raspunsul tau, path-ul nu se schimba setand CorFlags.

Edited by Erase

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...