小编Joe*_*man的帖子

Response.TransmitFile损坏文件

我的服务器上有一个文件,或者在本地主机中有一个文件.我想使用此代码将其传输给用户:

        Response.ContentType = "application/pdf";
        Response.AppendHeader("Content-Disposition", "attachment; filename=buylist.pdf");
        Response.TransmitFile(Server.MapPath("~/buylist.pdf"));

        Response.ContentType = "application/csv";
        Response.AppendHeader("Content-Disposition", "attachment; filename=buylist.csv");
        Response.TransmitFile(Server.MapPath("~/buylist.csv"));
Run Code Online (Sandbox Code Playgroud)

我知道我试图传输的文件很好,我甚至尝试添加,Response.Close()但每次文件损坏.csv给我页面的HTML.我真的迷路了.

c# asp.net

2
推荐指数
1
解决办法
2698
查看次数

意外的标记 ')'

我正在尝试编写一个bash脚本.我想通过系列表达式查找文件.我正在使用这一行:

find /etc \( \( -perm +222 -not -user root \) -or \( \(-perm -022 -or -perm -002 -or -perm -020 /) -user root /) /) -ls

我保持一个错误,但问题是,我得到无法找到实际上是导致错误.

bash

2
推荐指数
1
解决办法
76
查看次数

关闭文件附加到电子邮件System.Net.Mail

我有一个文件,我附加到ASP.NET应用程序中的电子邮件.问题是该过程不会放弃该文件.如何关闭方法中的文件,以便我可以在我的程序中再次使用它?

Attachment data = new Attachment(@"\\WIN-UWPWZ7Z3RKX\wwwroot\katipro\skus.txt");
m.Attachments.Add(data); 

SmtpClient s = new SmtpClient("smtp.gmail.com", 587);
s.Send(m);
Run Code Online (Sandbox Code Playgroud)

在我调用该方法后,它不允许我再次写入该文件而没有错误.

c# system.net.mail

1
推荐指数
1
解决办法
5713
查看次数

没有用于调用"qsort"的匹配函数

我似乎无法让qsort在我的问题中工作.我环顾四周,我的代码应该是正确的.

int file::compare (const void * a, const void * b)
{
     fileinfo* fa = (fileinfo*)a;
     fileinfo* fb = (fileinfo*)b;
     return (*(int*)fa->inode - *(int*)fb->inode);
}

void file::print()
{
    qsort((void *)files, 100, sizeof(fileinfo), compare);
}
Run Code Online (Sandbox Code Playgroud)

files是一个fileinfo数组.struct fileinfo是一个包含文件名称和inode的结构.

c++ qsort

1
推荐指数
1
解决办法
1060
查看次数

fopen() 的问题

因此,我正在编写一个小实用程序来格式化我的清单文件,以便我可以将其导入到预先存在的数据库中。我在尝试执行 fscanf 时遇到了一个大问题。我过去读过大量的 c 文件。我在这里做错了什么。

根据克里斯托弗的建议进行编辑仍然为空。

#include <stdio.h>
#include <string.h>

int main ()
{

FILE* stream;
FILE* output;
char sellercode[200];
char asin[15];
string sku[15];
string fnsku[15];
int quality;

stream = fopen("c:\out\dataextract.txt", "r");
output = fopen("c:\out\output.txt", "w");

if (stream == NULL)
{
    return 0;
}

for(;;)
{
    //if (EOF) break;
    fscanf(stream, "%s", sku);
    fprintf(output, "%s %s  %s  %s  %i\n", sku, fnsku, asin, quality);
}
 return 0;
 }
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
3195
查看次数

初始化继承类中不同对象的列表

我有一个基类如下

    protected BaseClasse()
    {
        this.myDic= new Dictionary<string, List<somethingThatWillChange>>();
    }

    protected Dictionary<string, List<somethingThatWillChange>> myDic{ get; set; }
Run Code Online (Sandbox Code Playgroud)

但是,这个类将有两个将继承它的类.其中一个继承类需要new Dictionary<string, List<Type1>>(),另一个需要new Dictionary<string, List<Type2>>().

Type1和Type2是类,Type1有7个字段(名称,年龄,时间,工作,汽车,工资,标题),Type2有3个字段(名称,年龄,时间).

所以在基类中,我想初始化或声明我的词典 new Dictionary<string, List<somethingGeneric>>()

然后在两个继承的类中,我想初始化或将其转换为适当的List<type1>List<type2>

  • 我不想声明多个词典.
  • 我不想在我的Type1和Type2类上继承

有没有办法做到这一点?

c# inheritance dictionary list

0
推荐指数
1
解决办法
256
查看次数

标签 统计

c# ×3

asp.net ×1

bash ×1

c ×1

c++ ×1

dictionary ×1

inheritance ×1

list ×1

qsort ×1

system.net.mail ×1