Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在angular(typescript)中将图像存储为字节数组_C#_Angular_Typescript_Components_Primeng - Fatal编程技术网

C# 如何在angular(typescript)中将图像存储为字节数组

C# 如何在angular(typescript)中将图像存储为字节数组,c#,angular,typescript,components,primeng,C#,Angular,Typescript,Components,Primeng,我有两个应用程序,一个是windows应用程序,另一个是web应用程序。Windows应用程序基于C#,web应用程序基于C#和angular。他们都使用同一个数据库,我的问题是处理文件。不幸的是,windows应用程序将文件内容存储在数据库中,所以我也必须在web应用程序中处理这个问题。以下是我在win应用程序中的代码: string FileName = System.IO.Path.GetFullPath(_fnames[i]);// GetFileName(_fname); strin

我有两个应用程序,一个是windows应用程序,另一个是web应用程序。Windows应用程序基于C#,web应用程序基于C#和angular。他们都使用同一个数据库,我的问题是处理文件。不幸的是,windows应用程序将文件内容存储在数据库中,所以我也必须在web应用程序中处理这个问题。以下是我在win应用程序中的代码:

string FileName = System.IO.Path.GetFullPath(_fnames[i]);// GetFileName(_fname);

string FileDescription = System.IO.Path.GetFullPath(_fnames[i]);    
string FileExtension = System.IO.Path.GetExtension(FileName);
System.IO.FileStream _fs = System.IO.File.Open(FileName, System.IO.FileMode.Open);
byte[] _f = new byte[_fs.Length];
_fs.Read(_f, 0, int.Parse(_fs.Length.ToString()));
byte[] FileContent = _f;
if (FileContent != null && FileContent.GetLength(0) > 0)
   {

     ReceiptDocDS.tblFilesRow _r = MainDS.tblFiles.NewtblFilesRow();
     _r.FileContent = FileContent;
     _r.FileDescription = FileDescription;
     // and other probs
  }
我想知道如何处理这个问题。我想将文件内容存储在
fileContet
prop中。因此,我必须阅读文件的内容,我进行了研究,结果如下:

onUpload(event) {
    const reader = new FileReader();
    for(let file of event.files) {
        reader.onload = (e) => e.target.result;
        const test =reader.readAsDataURL(new Blob([file.objectURL.changingThisBreaksApplicationSecurity]));
        this.uploadedFiles.push(file);
    }
}
这就是这个.file中的内容:

lastModified: 1543877513859
lastModifiedDate: Tue Dec 04 2018 02:21:53 GMT+0330 (Iran Standard Time) {}
name: "ali.jpg"
objectURL: SafeUrlImpl
changingThisBreaksApplicationSecurity: "blob:http://localhost:4200/0ae15950-5bfd-448c-b002-04ed2f27e622"
__proto__: SafeValueImpl
size: 16196
type: "image/jpeg"
webkitRelativePath: ""
我希望在这一行中以字节数组的形式获取图像的内容:

const test =reader.readAsDataURL(new Blob([file.objectURL.changingThisBreaksApplicationSecurity]));
但测试中并没有任何东西。那么这怎么可能呢?非常感谢你的阅读