2

我正在尝试在计算列公式中使用“文件大小”(又名“FileSizeDisplay”)。

“文件大小”是现有列(默认 SP 不是自定义)。但在任何库的“插入列”列表中不可用。如果手动将其作为 [File Size] 或 [FileSizeDisplay] 添加到公式中,SP 会显示一条错误消息,指出它不存在。

我要做的就是通知用户图像太大。不试图禁止文件大小上传或任何类似的技术。只想要一个计算列来显示一条消息。如果列值可用,则以下将起作用:

=IF([File Size]>50000,"Image is too big","Image is sized correctly")

或者

=IF([FileSizeDisplay]>50000,"Image is too big","Image is sized correctly")

有谁知道为什么这个专栏不可用?

干杯

4

1 回答 1

0

您首先要获取文件大小:获取文件大小,然后您可以在弹出窗口中显示消息或您想要的方式

using System;
using System.IO;

class Program
{
    static void Main()
    {
    // The name of the file
    const string fileName = "test.txt";

    // Create new FileInfo object and get the Length.
    FileInfo f = new FileInfo(fileName);
    long s1 = f.Length;

    // Change something with the file. Just for demo.
    File.AppendAllText(fileName, " More characters.");

    // Create another FileInfo object and get the Length.
    FileInfo f2 = new FileInfo(fileName);
    long s2 = f2.Length;

    // Print out the length of the file before and after.
    Console.WriteLine("Before and after: " + s1.ToString() +
        " " + s2.ToString());

    // Get the difference between the two sizes.
    long change = s2 - s1;
    Console.WriteLine("Size increase: " + change.ToString());
    }
}
于 2012-07-09T13:57:41.933 回答