实现类似百度文库效果,防止用户下载。
先说一下我的方法吧
1、下载并安装Macromedia FlashPaper 2
2、将文件上传到服务器,包括的格式doc/xsl/ppt/vsd/txt/jpg...
3、在后台调用FlashPrinter.exe将上传的文件转换成SWF格式。即上传之后就立即转换。
代码如下:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
public void ConvertToSWF(string oldFile, string swfFile) { System.Diagnostics.Process pc = new System.Diagnostics.Process(); pc.StartInfo.FileName = @"C:\Program Files\Macromedia\FlashPaper 2\FlashPrinter.exe"; pc.StartInfo.Arguments = string.Format("{0} -o {1}", oldFile, swfFile); pc.StartInfo.CreateNoWindow = true; pc.StartInfo.UseShellExecute = false; pc.StartInfo.RedirectStandardInput = true; pc.StartInfo.RedirectStandardOutput = true; pc.StartInfo.RedirectStandardError = true; pc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; pc.Start(); pc.WaitForExit(); pc.Close(); pc.Dispose(); } |
4、查看文件的时候找到对应的SWF文件,在浏览器中直接浏览。
浙公网安备 33010602011771号