文件读取权限 [英] File reading permission

查看:86
本文介绍了文件读取权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个站点,需要从任何地方浏览文件,读取文件并将其转换为二进制形式并将其存储在数据库中.

这部分仅在我的系统上仅对少数几个文件有效.当我ammesign我自己的桌面文件时,我无法读取文件-它给了我权限被拒绝的错误,并且其他网络系统也存在相同的问题.

这里的主要问题是我无法从网络和桌面读取某些文件.

当我指定impersonate = true时,它可以正常工作,但是当我从其他系统浏览该应用程序时,它正在尝试对用户进行身份验证,但是我没有为其设置任何用户名或密码.

I am developing a site where I need to browse files from anywhere, read files, and convert them to binary form and store them in a database.

This part is working fine for only a few files only on my system. When I amm accesign my own desktop files I am not able to read files - it gives me permission denied errors, and the same problem exists for other network systems.

The main problem here is I am not able to read some of the files from the network and the desktop.

When I specify impersonate=true, it works fine, but when I browse the application from other systems, it is trying to authenticate users, but I have not set any username or password for it.

How can I solve this problem?

推荐答案

您对网站"一词的使用使我觉得您正在写网站.还是您正在编写桌面应用程序?要在任何地方访问文件,都需要获得许可.您不能编写代码来回避这一事实,如果可以的话,权限系统将毫无用处.您可以在Vista和Weven上以管理员身份运行您的应用程序.基本上,我告诉您很多随机的内容,因为您的帖子是如此随机且毫无意义.尝试发布一些代码,告诉我们您使用的是什么操作系统,因为它与文件许可权有关,并且如果您正在编写网站或客户端应用程序,则请保持清楚.
Your use of the word ''site'' makes me think you''re writing a website. Or are you writing a desktop app ? To access files anywhere, you need permission. You can''t write code to sidestep that fact, if you could, then the permissions system would be useless. You can run your apps as admin on Vista and Weven. Basically, I am telling you a lot of random stuff because your post is so random and meaningless. Try posting some code, telling us what OS you''re using, as it''s relevant to file permissions, and be clear if you''re writing a web site or a client side app.


您好,
我正在开发一个网站,其设计如下

Hi,
I''m developing a Website, the design is the following

<pre lang="xml"><asp:FileUpload id="FileUploadControl" runat="server"   visible="false"/>&nbsp;<input type="file" runat="server" id="fileup" >&nbsp;<asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" Visible="true" CausesValidation="false"/>&nbsp;<asp:HyperLink ID="HlPhoto1" runat="server" CssClass="homelinkcls"
                   ToolTip="Click here to view the file" Target="new"
                   onclick="javascript:window.open('''',''new'',''menubar=0,hotlinks=0,left=0,top=0,resizable=1,scrollbars=1'')"
                   Visible="true"></asp:HyperLink>&nbsp;<asp:ImageButton
   ImageUrl="~/Images/Delete.gif" id="imgremove" runat="server"
   onclick="imgremove_Click" Visible="false" CausesValidation="false" Height="16px" Width="16px" ToolTip="Click to remove the file"/><asp:Label runat="server" id="UploadedFile" />
                   <input type="hidden" name="typeoffile" runat="server" id="typeoffile" />
                  <input type="hidden" name="myfilename" id="myfilename" runat="server" />







以下是上传按钮事件的代码







The code behind of the upload button event is teh following

FileInfo finfo;
finfo = new FileInfo(myfilename.Value);
if (finfo.Length <= 0) //here im getting the error
<pre lang="cs">{
                            HlPhoto1.Visible = false;
                            imgremove.Visible = false;
                            UploadedFile.Text = "Upload status: The file has no data!";
                            myfilename.Value = null;
                        }


else


else

if (finfo.Length > 0 && finfo.Length < 1048576)
                            {


                                string imgval = filename;
                                HlPhoto1.Visible = true;
                                imgval = imgval.Replace(" ", "~");
                                HlPhoto1.NavigateUrl = "../ViewImage/viewimage.aspx?srcval=" + myfilename.Value.Trim();
                                HlPhoto1.Text = "View";
                                HlPhoto1.Visible = true;
                                imgremove.Visible = true;





                            }












这篇关于文件读取权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆