- [C#] Hướng dẫn convert HTML code sang PDF File trên NetCore 7 Winform
- [C#] Hướng dẫn viết ứng dụng chat với Gemini AI Google Winform
- Hướng dẫn khóa file bằng nhiều process id, không cho xóa tập tin
- Hướng dẫn cách tạo Product Id cho ứng dụng phần mềm XXXXX-XXXXX-XXXXX-XXXXX
- [SQLSERVER] Hướng dẫn tạo script sql từ ứng dụng Sqlserver management Studio
- [C#] Hướng dẫn sử dụng thư viện AutoITx lấy id và password Ultraviewer trên winform
- [VB.NET] Hướng dẫn lấy thông tin tài khoản đăng nhập windows và khởi động lại ứng dụng ở chế độ Administrator
- [C#] Sử dụng thư viện Polly gửi lại request api khi request bị lỗi hay rớt mạng
- [DEVEXPRESS] Chia sẻ source code tạo báo cáo report in tem nhãn label trên C# winform
- [DEVEXPRESS] Hướng dẫn vẽ biểu đồ Bar Chart trên Winform
- [C#] Tạo form đăng nhập và đăng ký với hiệu ứng Sliding Animation Effect
- [C#] Hướng dẫn tạo thanh toán đơn hàng qua mã vạch VietQR sử dụng API PayOS hoàn toàn miễn phí
- [C#] Hướng dẫn ghi log ra RichTextBox giống Console trên Winform sử dụng thư viện Serilog
- [C#] Hướng dẫn cách tạo mã QR Code trên file Excel
- [VB.NET] Gởi tin nhắn và file đính kèm qua ứng dụng gởi tin nhắn Whats App
- [C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform
- [TOOL] Chia sẻ phần mềm thay đổi thông tin cấu hình máy tính
- [C#] Hướng dẫn Export dữ liệu ra file Microsoft Word Template
- [C#] Chia sẻ source code tool kiểm tra domain website
- [C#] Hướng dẫn tạo file PDF sử dụng thư viện QuestPDF
[C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
Xin chào các bạn trẻ, bài viết hôm nay mình sẻ hướng dẫn các bạn cách chia sẻ file từ ứng dụng Winform sang Zalo APP Chat C#.
[C#] SHARE FILE, FOLDER TO ZALO APP
Trong lập trình ứng dụng, nhiều lúc các bạn xuất dữ liệu ra file Excel, hay PDF và các bạn muốn sau khi xuất file này ra, thì mình sẽ gởi báo cáo này cho bạn bè, sếp...
Hình ảnh Demo Ứng dụng Share File, Folder Zalo C#:
Sau khi chọn File và bấm nút Share ta được kết quả như hình bên dưới.
Sau đó, chúng ta chọn list người muốn chia sẻ và bấm chia sẻ file là xong.
Video demo share File Zalo C#:
Để chia sẽ File hoặc Folder bạn bạn xem dòng lệnh sau:
C:UsersNGUYENTHAOAppDataLocalProgramsalosl.exe "%1" "C:UsersNGUYENTHAOAppDataLocalProgramsaloalo.exe"
$files --si-timeout 1000
Trong đó với $files
là đường dẫn File hoặc Folder mà các bạn muốn chia sẽ cho bạn bè hay ai đó.
Và thực hiện, các bạn chỉ cần viết app, và gọi lệnh CMD.exe và thực hiện đoạn lệnh trên là xong.
Full source code share File With Zalo c#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShareFileWithZalo
{
public partial class Form1 : Form
{
public string URI;
public Form1()
{
InitializeComponent();
URI = @"E:soft";
}
private void Form1_Load(object sender, EventArgs e)
{
NativeMethods.SHFILEINFO shfi = new NativeMethods.SHFILEINFO();
IntPtr hSysImgList = NativeMethods.SHGetFileInfo("",
0,
ref shfi,
(uint)Marshal.SizeOf(shfi),
NativeMethods.SHGFI_SYSICONINDEX
| NativeMethods.SHGFI_SMALLICON);
Debug.Assert(hSysImgList != IntPtr.Zero);
IntPtr hOldImgList = NativeMethods.SendMessage(listView1.Handle,
NativeMethods.LVM_SETIMAGELIST,
NativeMethods.LVSIL_SMALL,
hSysImgList);
if (hOldImgList != IntPtr.Zero)
{
NativeMethods.ImageList_Destroy(hOldImgList);
}
listView1.View = View.Details;
listView1.Columns.Add("Name", 500);
NativeMethods.SetWindowTheme(listView1.Handle, "Explorer", null);
string[] s = Directory.GetFileSystemEntries(URI);
foreach (string file in s)
{
IntPtr himl = NativeMethods.SHGetFileInfo(file,
0,
ref shfi,
(uint)Marshal.SizeOf(shfi),
NativeMethods.SHGFI_DISPLAYNAME
| NativeMethods.SHGFI_SYSICONINDEX
| NativeMethods.SHGFI_SMALLICON);
Debug.Assert(himl == hSysImgList);
listView1.Items.Add(shfi.szDisplayName, shfi.iIcon);
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
{
var item = listView1.SelectedItems[0];
txt_file.Text = URI + "\" + item.Text;
}
}
private void btnShare_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txt_file.Text))
{
string FILE_SHARE = """ + txt_file.Text + """;
var PATH_SPECIAL_PROGRAMS = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.None) + @"Programs";
string AGRUMENTS = $@"{PATH_SPECIAL_PROGRAMS}alosl.exe "" % 1"" ""{PATH_SPECIAL_PROGRAMS}aloalo.exe"" {FILE_SHARE} --si-timeout 1000";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = $"/C {AGRUMENTS}";
process.StartInfo = startInfo;
process.Start();
}
else
{
MessageBox.Show("Không có gì để share hết, bạn ơi!");
}
}
}
}
Thanks for watching!