小编wak*_*aka的帖子

为什么File.Move没有按预期工作?

我试图将所有文件移动rootFolderPathdestinationPath

try
{
    string rootFolderPath = @"D:\Log_siteq\";
    if (!Directory.Exists(Path.Combine(@"D:\Log_takaya\" + comboBox1.SelectedItem.ToString())))
    {
        System.IO.Directory.CreateDirectory(Path.Combine(@"D:\Log_takaya\" + comboBox1.SelectedItem.ToString()));
    }


    string destinationPath = Path.Combine(@"D:\Log_takaya\" + comboBox1.SelectedItem.ToString() );
    string fileTypes = @"*.*";
    string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, fileTypes);
    foreach (string file in fileList)
    {
        string ext = Path.GetExtension(file);
        string destination = Path.Combine(destinationPath,file);                 
        File.Move( file,destination);
        MessageBox.Show(file);
        MessageBox.Show(destination);
    }
}
catch(Exception ex)
{
    MessageBox.Show(ex.ToString());
}
Run Code Online (Sandbox Code Playgroud)

显然MessageBox.Show(file);显示我的根文件夹路径(正常情况下)但MessageBox.Show(destination);显示我同样的事情.

是什么赋予了?它只是将我file从我的根文件夹中移动到同一个文件夹中.我没有得到什么东西?

c#

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

读取CSV文件时忽略双引号之间的逗号

使用C#语言制作的CSV阅读器。它可以正常工作,但是我不能忽略双引号行值之间的逗号(',')。

示例:“ aa”,“ aa,bb”,“ cc”

它看起来像

Col1 Col2 Col3 Col4
aa   aa   bb   cc 
Run Code Online (Sandbox Code Playgroud)

而不是这样,它应显示为

Col1 Col2 Col3 
aa   aabb cc 
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

public void LoadFile(String path)
{
    Table.Rows.Clear();
    Table.Columns.Clear();
    StreamReader file = File.OpenText(path);
    String[] header = file.ReadLine().Split(',');
    for (int i = 0; i < Table.ColumnCount; i++)
    {
        Table.Columns[i].Name = "Col " + i;}
        String row = "";
        while ((row = file.ReadLine()) != null)
        {
            Table.Rows.Add(row.Split(','));
        }
        file.Close();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# csv streamreader

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

如何格式化“5 分钟”、“1 小时”、“昨天”、“1 周前”等日期?

我正在尝试获得类似于 facebook 发布日期/时间的内容。像 1 分钟、1 小时、昨天、一周前等。

这是我用来获取这种格式的函数:( Oct-22 17:28 PM)

func convertTime(serverTime: Double)  -> String {
    let serverTime = serverTime
    let date = Date(timeIntervalSince1970: serverTime)
    let dateFomatter = DateFormatter()
    dateFomatter.dateFormat = "MMM-dd HH:mm a"
    let strDate = dateFomatter.string(from: date)
    print("This is the post's date: \(strDate)")

    return strDate
}
Run Code Online (Sandbox Code Playgroud)

nsdate xcode6 swift3

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

带 ROUND 和除法的 sql 查询

显示 GDP 至少为 1 万亿(1000000000000;即 12 个零)的国家的名称和人均 GDP。将此值四舍五入到最接近的 1000。显示万亿美元国家的人均 GDP 到最接近的 1000 美元。

SELECT name ,
       ROUND(gdp/population,0.01)

from world
where gdp >= 1000000000000
Run Code Online (Sandbox Code Playgroud)

然而这会产生错误。

可以在这里测试任务

mysql sql

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

如何在c#中将数字转换为数字零?

我想将数字转换为零

int instore = docvotdig;
int invot = docstoredig;
int diffrent = docvotdig - docstoredig;
int instore = docvotdig;
Run Code Online (Sandbox Code Playgroud)

我想将结果转换为00000,如果结果2我想要它'00',如果3'000'那样.

c#

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

等待运算符出错

我的代码有问题.我怎么解决这个问题?等待运算符中存在此问题.

 public MyModel() 
    {
        HttpClient client = new HttpClient();
        HttpResponseMessage response = await client.GetAsync("https://api.vkontakte.ru/method/video.get?uid=219171498&access_token=d61b93dfded2a37dfcfa63779efdb149653292636cac442e53dae9ba6a049a75637143e318cc79e826149");
        string googleSearchText = await response.Content.ReadAsStringAsync();
        JObject googleSearch = JObject.Parse(googleSearchText);
        IList<JToken> results = googleSearch["response"].Children().Skip(1).ToList();
        IList<MainPage1> searchResults = new List<MainPage1>();
        foreach (JToken result in results)
        {
            MainPage1 searchResult = JsonConvert.DeserializeObject<MainPage1>(result.ToString());
            searchResults.Add(searchResult);

        }
Run Code Online (Sandbox Code Playgroud)

.net c# async-await

-4
推荐指数
2
解决办法
4506
查看次数

需要解释短代码片段

我刚做了这个简短的节目.有人可以解释为什么我在这里得到2?

这是代码

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int variable;
    int a;
    a=variable;
    a=200;
    printf("%d",variable);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c variables type-conversion

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

标签 统计

c# ×4

.net ×1

async-await ×1

c ×1

csv ×1

mysql ×1

nsdate ×1

sql ×1

streamreader ×1

swift3 ×1

type-conversion ×1

variables ×1

xcode6 ×1