Example #1
0
        //Local Operations
        static async Task <MessageResponse> RemoveFileMessage(Message message, object userContext)
        {
            //For test purpose only
            //message.Properties.Add("sourcePath", @"C:/Users");
            //message.Properties.Add("sourceFilename", @"Test.txt");
            //*********************

            logReceivedMessage(message);

            #region Checking required properties
            if (!validateStringParams(message, "sourcePath", "sourceFilename"))
            {
                return(MessageResponse.Abandoned);
            }
            #endregion

            // Process code here
            try
            {
                await localFileIO.RemoveFile(message.Properties["sourcePath"], message.Properties["sourceFilename"]);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error deleting local file: {ex.Message}");
            }

            Console.WriteLine("Done!");

            return(MessageResponse.Completed);
        }
Example #2
0
        public void WriteAndDeleteFile_FileGone()
        {
            var io = new LocalFileIO("foo", "bar");

            io.WriteFile(".", "test2.txt", GenerateTestBytes(), false).Wait();
            io.RemoveFile(".", "test2.txt").Wait();

            Assert.IsFalse(File.Exists(".\\test2.txt"));
        }