Thứ Hai, 30 tháng 9, 2019

Zip folder using 7-Zip Command Line

cd C:\Program Files\7-Zip

7z a -t7z "D:\Document.7z" "D:\Document"

Thứ Năm, 12 tháng 9, 2019

Configure TortoiseSVN to use Visual Studio 2015 for Diff Viewer (Updated including Visual Studio 2017, 2019)

Settings -> Diff Viewer -> External -> paste the command as below:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe -diff %base %mine

or

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsDiffMerge.exe /t %base %mine %bname %yname

Visual Studio 2017 Professional:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe -diff %base %mine

Visual Studio 2019 Enterprise:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe -diff %base %mine



Thứ Sáu, 9 tháng 8, 2019

[T-SQL] Sizing Database In Advance


USE [master]
GO
ALTER DATABASE [tempdb] MODIFY FILE ( NAME = N'tempdev', SIZE = 31457280KB )
GO
ALTER DATABASE [tempdb] MODIFY FILE ( NAME = N'templog', SIZE = 62914560KB )
GO

USE [tempdb];
EXEC sp_helpfile;

Thứ Hai, 5 tháng 8, 2019

[T-SQL] Change Database Location


SELECT name, physical_name AS CurrentLocation, state_desc  
FROM sys.master_files  
WHERE database_id = DB_ID(N'tempdb');
GO

-- Stop SQL Server
-- Copy files to new location
-- Start SQL Server

USE master;
GO

ALTER DATABASE tempdb 
MODIFY FILE (NAME = tempdev, FILENAME = 'E:\MSSQL\DATA\tempdb.mdf');
GO

ALTER DATABASE tempdb 
MODIFY FILE (NAME = templog, FILENAME = 'E:\MSSQL\DATA\templog.ldf');
GO

-- Restart SQL Server


-- https://docs.microsoft.com/en-us/sql/relational-databases/databases/move-system-databases?view=sql-server-2017
-- https://www.mytechmantra.com/LearnSQLServer/How-to-Move-TempDB-to-New-Drive-in-SQL-Server/

Chủ Nhật, 23 tháng 12, 2018

[C#] Mapping Network Drive

using IWshRuntimeLibrary;

string drive = ConfigurationManager.AppSettings["Drive"];
string folder = ConfigurationManager.AppSettings["Folder"];
string userName = ConfigurationManager.AppSettings["Username"];
string password = ConfigurationManager.AppSettings["Password"];

IWshNetwork_Class network = new IWshNetwork_Class();

try
{
 network.RemoveNetworkDrive(drive);
}
catch (Exception ex)
{

}

try
{
 network.MapNetworkDrive(drive, folder, Type.Missing, userName, password);
}
catch (Exception ex)
{

}

Thứ Sáu, 21 tháng 12, 2018

[C#] Open file without locking

var stream = File.Open(filePath, FileMode.Open,
 FileAccess.Read,
 FileShare.ReadWrite);