如何使用 .Net 以只读格式保存 .xlsm 文件

发布于 2024-12-18 23:25:54 字数 117 浏览 2 评论 0原文

如何使用 .Net 代码将我的 .xlsm 文件以只读格式保存在共享驱动器中。当我打开它时,它显示为只读。但保存后,当我打开时,我可以编辑。

我需要在保存时采用只读格式。请帮忙。

How do I save my .xlsm file in read-only format in a shared drive using .Net code. When I open it is showing as read-only. But after saving, when I open I was able to edit.

I need to have read-only format while saving. please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

影子是时光的心 2024-12-25 23:25:54

中 File 对象的 IsReadOnly 属性

使用msdn (http ://msdn.microsoft.com/en-us/library/system.io.fileinfo.isreadonly.aspx):

    // Sets the read-only value of a file.
    public static void SetFileReadAccess(string FileName, bool SetReadOnly)
    {
        // Create a new FileInfo object.
        FileInfo fInfo = new FileInfo(FileName);

        // Set the IsReadOnly property.
        fInfo.IsReadOnly = SetReadOnly;

    }

Use the IsReadOnly property on the File object

from the msdn (http://msdn.microsoft.com/en-us/library/system.io.fileinfo.isreadonly.aspx):

    // Sets the read-only value of a file.
    public static void SetFileReadAccess(string FileName, bool SetReadOnly)
    {
        // Create a new FileInfo object.
        FileInfo fInfo = new FileInfo(FileName);

        // Set the IsReadOnly property.
        fInfo.IsReadOnly = SetReadOnly;

    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文