WIN32_FIND_DATA это правда [закрыто]C#

Место общения программистов C#
Ответить
Anonymous
 WIN32_FIND_DATA это правда [закрыто]

Сообщение Anonymous »

Это правда? Я хочу использовать WIN32_FIND_DATA для C#. Я хочу проверить, есть ли в приведенном ниже коде какие-либо ошибки для C#.
Пожалуйста, покажите мне другой способ, если вы найдете другой код получше.
Привет всем, привет. бродяга bejafoanc nsfkck Это правда? Я хочу использовать WIN32_FIND_DATA для C#. Я хочу проверить, есть ли в приведенном ниже коде какие-либо ошибки для C#.
Пожалуйста, покажите мне другой способ, если вы найдете другой код получше.
Привет всем, привет. бродяга bejafoanc nsfkck
using System.Text;

class Program
{
static void Main()
{
// Đăng ký nhà cung cấp mã hóa
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

// Lấy mã hóa MS932
Encoding ms932 = Encoding.GetEncoding(932);

// Kiểm tra tên mã hóa
Console.WriteLine($"Tên mã hóa: {ms932.EncodingName}");
}
}

using System;
using System.Text;

class Program
{
static void Main()
{
// 1. Ký tự đặc biệt
char specialChar = '>';

// 2. Lấy mã ASCII
int asciiValue = (int)specialChar;
Console.WriteLine($"Ký tự: {specialChar}, Mã ASCII: {asciiValue}");

// 3. Chuyển đổi sang byte array với MS932
byte[] ms932Bytes = Encoding.GetEncoding("windows-932").GetBytes(specialChar.ToString());

// 4. Chuyển đổi lại về chuỗi
string ms932String = Encoding.GetEncoding("windows-932").GetString(ms932Bytes);

// 5. Hiển thị kết quả
Console.WriteLine($"Chuỗi MS932: {ms932String}");
}
}

using System;
using System.Text;

class Program
{
static void Main()
{
// Chuỗi UTF-8
string utf8String = "Xin chào";

// Chuyển đổi từ UTF-8 sang MS932
Encoding ms932 = Encoding.GetEncoding("ms932");
byte[] ms932Bytes = ms932.GetBytes(utf8String);

// Chuyển đổi lại từ MS932 về UTF-8 (nếu cần)
string convertedString = ms932.GetString(ms932Bytes);

// Hiển thị kết quả
Console.WriteLine("Chuỗi sau khi chuyển đổi: " + convertedString);
}
}

using System;
using System.IO;

class Program
{
static void Main()
{
string path = @"C:\path\to\directory";
DirectoryInfo dirInfo = new DirectoryInfo(path);

// Liệt kê tất cả các tệp trong thư mục
FileInfo[] files = dirInfo.GetFiles();

foreach (FileInfo file in files)
{
Console.WriteLine($"Tên: {file.Name}, Kích thước: {file.Length} bytes, Ngày tạo: {file.CreationTime}");
}
}
}

using System;
using System.Text;

class Program
{
static void Main()
{
// Chuỗi mẫu
string originalString = "Xin chào";

// Chuyển đổi từ UTF-8 sang MS932
Encoding ms932 = Encoding.GetEncoding("ms932");
byte[] ms932Bytes = ms932.GetBytes(originalString);

// Chuyển đổi từ MS932 về UTF-8
string decodedString = ms932.GetString(ms932Bytes);

Console.WriteLine(decodedString);
}
}


string url = "http://localhost:8080/api/upload"; // Địa chỉ API
string filePath = @"D:\test1.txt"; // Đường dẫn file muốn upload
string textData = "some text"; // Dữ liệu văn bản

using (var httpClient = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
// Tạo phần dữ liệu văn bản
var textContent = new StringContent(textData);
content.Add(textContent, "textData");

// Tạo phần dữ liệu file
var fileContent = new ByteArrayContent(File.ReadAllBytes(filePath));
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");
content.Add(fileContent, "files[]", Path.GetFileName(filePath));

// Gửi request POST với nội dung multipart/form-data
HttpResponseMessage response = await httpClient.PostAsync(url, content);

// Kiểm tra phản hồi từ server
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseBody);
}
else
{
Console.WriteLine($"Failed to upload: {response.StatusCode}");
}
}
}



Подробнее здесь: https://stackoverflow.com/questions/790 ... a-its-true
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»