因此,我有一个c#应用程序,它需要在托管在我的web服务器上的文本文件中使用一些代码(path:https://example.com/example.txt)。
文本文件的内容包含一些已编译的代码,下面是编译代码的一个片段:
*ü
*²0 ¾6- +*
+
*²0 ¾6- +S
+;
*²0 ¾6- +y
+`
*²0 ¾6- +Ÿ
+‡
*²0 ¾6- +È
+°
*²0 ¾6-
C
*s0 µ6--. y +ð
+Ù
*s0 ¾6-
+ð
+þ
*s0 ¾6-
, +ð
,
*s0 ¾6-
¶ +ð
,
*s0 ¾6-
û +ð
,
*s0 ¾6-
+ð
,/
*s0 ¾6-
C
*W0 µ6-
,W ,G
,>在我的c#应用程序中,我尝试了多种方法从我的web服务器上的文本文件中检索内容,这种方式不会破坏编译后的代码结构,例如:
string RetrieveText;
WebClient con = new WebClient();
RetrieveText = con.DownloadString("https://example.com/example.txt");
MessageBox.Show(RetrieveText);这方面的问题是,当我的c#应用程序被执行并且MessageBox.Show()弹出时,编译的代码会得到一些“无组织的”,并且我的web服务器上的文本文件中的一些编译代码行会随机地得到换行和删除空间,例如,当使用上面所示的c#示例中的DownloadString()检索编译后的代码时,MessageBox输出如下:
上面显示的编译代码片段,但在我使用c#使用DownloadString()检索托管在web服务器上的文本文件的内容之后
*ü
*²0 ¾6- +* +
*²0 ¾6- +S +; *²0 ¾6- +y
+` *²0 ¾6- +Ÿ
+‡ *²0 ¾6- +È +° *²0 ¾6-
*s0 µ6--. y +ð
+Ù *s0 ¾6- +ð
+þ *s0 ¾6- , +ð
, *s0 ¾6- ¶ + , *s0 ¾6- + , *s0 ¾6-
+ ,/ *s0 ¾6 C
*W0 µ6 ,W ,G ,>正如您所看到的,编译后的代码已经从原来的布局/结构中改变了,所以基本上我的问题是,是否有一种方法可以使用c#从托管在web服务器上的文本文件中检索内容?如果是这样的话,我如何检索文本文件的内容,但又不干扰托管在我的web服务器上的文本文件中编译代码的布局/结构?
我需要能够在我的c#应用程序中使用need服务器上文本文件的内容,如下所示:
this.CustomCONSOLE.SetMemory(566697660U, [HERE IS WERE I NEED TO PUT THE CONTENTS OF THE TEXT FILE ON MY WEB SERVER]);希望这个问题是有意义的
发布于 2016-02-27 03:35:34
您应该使用WebClient的DownloadData而不是DownloadString。DownloadString必须尝试找出编码,并应用到给您一个字符串。你根本不想完成这个转变。
发布于 2016-02-27 03:36:51
不要对已编译的字符串使用DownloadString。此函数设计仅适用于普通字符串。使用DownloadData代替。
WebClient wc = new WebClient();
// Get binary data
byte[] downloadData = wc.DownloadData("https://example.com/example.txt");
// You can download your server file directly use download manager tools (etc. IDM) save it to "serverfile.bin" and compare it
byte[] orgBytes = File.ReadAllBytes("D:\\serverfile.bin");
// using System.Linq;
bool isTwoFileEqual = downloadData.SequenceEqual(orgBytes);
// The result should be True
Console.WriteLine(isTwoFileEqual);https://stackoverflow.com/questions/35665256
复制相似问题