• <tfoot id='Gxov7'></tfoot>
    <i id='Gxov7'><tr id='Gxov7'><dt id='Gxov7'><q id='Gxov7'><span id='Gxov7'><b id='Gxov7'><form id='Gxov7'><ins id='Gxov7'></ins><ul id='Gxov7'></ul><sub id='Gxov7'></sub></form><legend id='Gxov7'></legend><bdo id='Gxov7'><pre id='Gxov7'><center id='Gxov7'></center></pre></bdo></b><th id='Gxov7'></th></span></q></dt></tr></i><div id='Gxov7'><tfoot id='Gxov7'></tfoot><dl id='Gxov7'><fieldset id='Gxov7'></fieldset></dl></div>
    1. <legend id='Gxov7'><style id='Gxov7'><dir id='Gxov7'><q id='Gxov7'></q></dir></style></legend>
        <bdo id='Gxov7'></bdo><ul id='Gxov7'></ul>

      <small id='Gxov7'></small><noframes id='Gxov7'>

        在 Windows 7 上创建文件会导致“访问被拒绝"例外

        Creating file on Windows 7 causes quot;Access deniedquot; exception(在 Windows 7 上创建文件会导致“访问被拒绝例外)
            <tbody id='3RIWc'></tbody>
        1. <legend id='3RIWc'><style id='3RIWc'><dir id='3RIWc'><q id='3RIWc'></q></dir></style></legend>

          1. <tfoot id='3RIWc'></tfoot>

            <small id='3RIWc'></small><noframes id='3RIWc'>

            <i id='3RIWc'><tr id='3RIWc'><dt id='3RIWc'><q id='3RIWc'><span id='3RIWc'><b id='3RIWc'><form id='3RIWc'><ins id='3RIWc'></ins><ul id='3RIWc'></ul><sub id='3RIWc'></sub></form><legend id='3RIWc'></legend><bdo id='3RIWc'><pre id='3RIWc'><center id='3RIWc'></center></pre></bdo></b><th id='3RIWc'></th></span></q></dt></tr></i><div id='3RIWc'><tfoot id='3RIWc'></tfoot><dl id='3RIWc'><fieldset id='3RIWc'></fieldset></dl></div>

                  <bdo id='3RIWc'></bdo><ul id='3RIWc'></ul>

                  本文介绍了在 Windows 7 上创建文件会导致“访问被拒绝"例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 Java 应用程序,用户可以使用此代码创建一个文本文件并将其保存在计算机上的任意位置:

                  I have a Java application were the user can create a text file and save it wherever he wants on his computer using this code :

                  File txtFile = new File( path );
                  Writer writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( txtFile ), "UTF-8" ) );  // Error occurs here.
                  

                  但许多使用 Windows 7 的用户报告说,当将文件保存到 C:" 时,他们会收到Access is denied"错误.我发现这是因为他们需要管理员权限才能在 Win7 中将文件保存在这样的路径中.

                  But many users using Windows 7 reported that when saving the file to "C:", they get "Access is denied" error. I found that this is because they need administrator permissions to save the file in such path in Win7.

                  除了向用户显示警告消息:您无法将文件保存在此路径"之外,我是否可以以某种方式将文件保存在此路径中,例如是否有办法通过 Java 代码或类似的方式在 Win7 中拥有管理员权限?

                  Instead of showing a warning message to the user: " You can't save the file at this path ", can i save the file in this path somehow, like if there is a way to have Administrator permissions in Win7 through Java code, or something like that ?

                  推荐答案

                  简答 - 否.

                  如果你需要保存到C盘,他们需要权限.如果这个程序只需要创建文件,你可以使用用户临时文件夹.请参阅 System.getProperty()

                  If you need to save to C drive, they need permissions. If this program just needs to create files, you can use the users temp folder. See System.getProperty()

                  这篇关于在 Windows 7 上创建文件会导致“访问被拒绝"例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                      • <tfoot id='YhSbu'></tfoot>

                            <tbody id='YhSbu'></tbody>

                          <small id='YhSbu'></small><noframes id='YhSbu'>

                            <bdo id='YhSbu'></bdo><ul id='YhSbu'></ul>
                            <i id='YhSbu'><tr id='YhSbu'><dt id='YhSbu'><q id='YhSbu'><span id='YhSbu'><b id='YhSbu'><form id='YhSbu'><ins id='YhSbu'></ins><ul id='YhSbu'></ul><sub id='YhSbu'></sub></form><legend id='YhSbu'></legend><bdo id='YhSbu'><pre id='YhSbu'><center id='YhSbu'></center></pre></bdo></b><th id='YhSbu'></th></span></q></dt></tr></i><div id='YhSbu'><tfoot id='YhSbu'></tfoot><dl id='YhSbu'><fieldset id='YhSbu'></fieldset></dl></div>

                          • <legend id='YhSbu'><style id='YhSbu'><dir id='YhSbu'><q id='YhSbu'></q></dir></style></legend>